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(a)redhat.com>
---
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 091a1dc0bc8f..2af878977a1b 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;
--
2.4.3