render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
c401cc
From 25157ff2a94700591dc1585d99c111f43b4a2dbe Mon Sep 17 00:00:00 2001
c401cc
Message-Id: <25157ff2a94700591dc1585d99c111f43b4a2dbe.1390394207.git.jdenemar@redhat.com>
c401cc
From: Eric Blake <eblake@redhat.com>
c401cc
Date: Thu, 16 Jan 2014 13:16:36 -0700
c401cc
Subject: [PATCH] Fix memory leak in virObjectEventCallbackListRemoveID()
c401cc
c401cc
https://bugzilla.redhat.com/show_bug.cgi?id=1047964
c401cc
c401cc
While running objecteventtest, it was found that valgrind pointed out the
c401cc
following memory leak:
c401cc
c401cc
==13464== 5 bytes in 1 blocks are definitely lost in loss record 7 of 134
c401cc
==13464==    at 0x4A0887C: malloc (vg_replace_malloc.c:270)
c401cc
==13464==    by 0x341F485E21: strdup (strdup.c:42)
c401cc
==13464==    by 0x4CAE28F: virStrdup (virstring.c:554)
c401cc
==13464==    by 0x4CF3CBE: virObjectEventCallbackListAddID (object_event.c:286)
c401cc
==13464==    by 0x4CF49CA: virObjectEventStateRegisterID (object_event.c:729)
c401cc
==13464==    by 0x4CF73FE: virDomainEventStateRegisterID (domain_event.c:1424)
c401cc
==13464==    by 0x4D7358F: testConnectDomainEventRegisterAny (test_driver.c:6032)
c401cc
==13464==    by 0x4D600C8: virConnectDomainEventRegisterAny (libvirt.c:19128)
c401cc
==13464==    by 0x402409: testDomainStartStopEvent (objecteventtest.c:232)
c401cc
==13464==    by 0x403451: virtTestRun (testutils.c:138)
c401cc
==13464==    by 0x402012: mymain (objecteventtest.c:395)
c401cc
==13464==    by 0x403AF2: virtTestMain (testutils.c:593)
c401cc
==13464==
c401cc
c401cc
(cherry picked from commit 34d52b3471a18c72b7a02e27d65857505d858a8e)
c401cc
c401cc
Conflicts:
c401cc
	src/conf/object_event.c - 1.2.1 refactoring to object_event not
c401cc
backported, so change applied directly in older domain_event.c instead
c401cc
c401cc
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
c401cc
---
c401cc
 src/conf/domain_event.c | 6 ++++++
c401cc
 1 file changed, 6 insertions(+)
c401cc
c401cc
diff --git a/src/conf/domain_event.c b/src/conf/domain_event.c
c401cc
index 19e3920..de55d08 100644
c401cc
--- a/src/conf/domain_event.c
c401cc
+++ b/src/conf/domain_event.c
c401cc
@@ -175,6 +175,9 @@ virDomainEventCallbackListRemove(virConnectPtr conn,
c401cc
             if (freecb)
c401cc
                 (*freecb)(cbList->callbacks[i]->opaque);
c401cc
             virObjectUnref(cbList->callbacks[i]->conn);
c401cc
+            if (cbList->callbacks[i]->dom)
c401cc
+                VIR_FREE(cbList->callbacks[i]->dom->name);
c401cc
+            VIR_FREE(cbList->callbacks[i]->dom);
c401cc
             VIR_FREE(cbList->callbacks[i]);
c401cc
 
c401cc
             if (i < (cbList->count - 1))
c401cc
@@ -225,6 +228,9 @@ virDomainEventCallbackListRemoveID(virConnectPtr conn,
c401cc
             if (freecb)
c401cc
                 (*freecb)(cbList->callbacks[i]->opaque);
c401cc
             virObjectUnref(cbList->callbacks[i]->conn);
c401cc
+            if (cbList->callbacks[i]->dom)
c401cc
+                VIR_FREE(cbList->callbacks[i]->dom->name);
c401cc
+            VIR_FREE(cbList->callbacks[i]->dom);
c401cc
             VIR_FREE(cbList->callbacks[i]);
c401cc
 
c401cc
             if (i < (cbList->count - 1))
c401cc
-- 
c401cc
1.8.5.3
c401cc