From fcc2aab688244d3e07c578080653ee526c056b38 Mon Sep 17 00:00:00 2001 From: Martin Kletzander Date: Thu, 11 Jun 2015 13:58:43 +0200 Subject: [PATCH] rpc: Fix possible crash when MDNSAddEntry fails If virNetServerMDNSAddEntry() fails when adding a service to a server, it doesn't decrease the number of services. Hence access to their members segfaults (e.g. when free()-ing the sruct). Signed-off-by: Martin Kletzander --- src/rpc/virnetserver.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c index 091a1dc0bc..2af878977a 100644 --- a/src/rpc/virnetserver.c +++ b/src/rpc/virnetserver.c @@ -974,8 +974,10 @@ int virNetServerAddService(virNetServerPtr srv, if (!virNetServerMDNSAddEntry(srv->mdnsGroup, mdnsEntryName, - port)) + port)) { + srv->nservices--; goto error; + } } srv->services[srv->nservices-1] = svc; -- GitLab