From b660238eb11d83c3d42bf400424ed5959498ac86 Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Thu, 4 Aug 2016 08:33:17 +0200 Subject: [PATCH] virObjectEventNew: Use virObjectUnref() to free virObjectEvent While no leak was observed yet, there might be one if virObjectEventClass is ever derived from another class. Because in that case plain VIR_FREE() will not call dispose() from parent classes possibly leaking some memory. Signed-off-by: Michal Privoznik --- src/conf/object_event.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/conf/object_event.c b/src/conf/object_event.c index bbef7f6bf2..b5a6a81a3a 100644 --- a/src/conf/object_event.c +++ b/src/conf/object_event.c @@ -649,13 +649,9 @@ virObjectEventNew(virClassPtr klass, event->eventID = eventID; event->remoteID = -1; - if (VIR_STRDUP(event->meta.name, name) < 0) { - VIR_FREE(event); - return NULL; - } - if (VIR_STRDUP(event->meta.key, key) < 0) { - VIR_FREE(event->meta.name); - VIR_FREE(event); + if (VIR_STRDUP(event->meta.name, name) < 0 || + VIR_STRDUP(event->meta.key, key) < 0) { + virObjectUnref(event); return NULL; } event->meta.id = id; -- GitLab