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 <mkletzan@redhat.com>
This commit is contained in:
Martin Kletzander 2015-06-11 13:58:43 +02:00
parent 5e55534b9a
commit fcc2aab688

View File

@ -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;