diff options
author | Eric Blake <eblake@redhat.com> | 2014-01-13 17:30:59 -0700 |
---|---|---|
committer | Eric Blake <eblake@redhat.com> | 2014-01-15 14:41:43 -0700 |
commit | 076a7eca5be9580e62aa07f30c185d8a96649eb1 (patch) | |
tree | 26aa59675472ac829da51d0ccabfd573c4ae665b | |
parent | a19f700b642115963ce6007cf22945870c9e8616 (diff) | |
download | libvirt-076a7eca5be9580e62aa07f30c185d8a96649eb1.tar.gz |
Fix memory leak in virObjectEventCallbackListRemoveID()
While running objecteventtest, it was found that valgrind pointed out the
following memory leak:
==13464== 5 bytes in 1 blocks are definitely lost in loss record 7 of 134
==13464== at 0x4A0887C: malloc (vg_replace_malloc.c:270)
==13464== by 0x341F485E21: strdup (strdup.c:42)
==13464== by 0x4CAE28F: virStrdup (virstring.c:554)
==13464== by 0x4CF3CBE: virObjectEventCallbackListAddID (object_event.c:286)
==13464== by 0x4CF49CA: virObjectEventStateRegisterID (object_event.c:729)
==13464== by 0x4CF73FE: virDomainEventStateRegisterID (domain_event.c:1424)
==13464== by 0x4D7358F: testConnectDomainEventRegisterAny (test_driver.c:6032)
==13464== by 0x4D600C8: virConnectDomainEventRegisterAny (libvirt.c:19128)
==13464== by 0x402409: testDomainStartStopEvent (objecteventtest.c:232)
==13464== by 0x403451: virtTestRun (testutils.c:138)
==13464== by 0x402012: mymain (objecteventtest.c:395)
==13464== by 0x403AF2: virtTestMain (testutils.c:593)
==13464==
(cherry picked from commit 34d52b3471a18c72b7a02e27d65857505d858a8e)
Conflicts:
src/conf/object_event.c - 1.2.1 refactoring to object_event not
backported, so change applied directly in older domain_event.c instead
-rw-r--r-- | src/conf/domain_event.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/conf/domain_event.c b/src/conf/domain_event.c index 19e392000e..de55d08796 100644 --- a/src/conf/domain_event.c +++ b/src/conf/domain_event.c @@ -175,6 +175,9 @@ virDomainEventCallbackListRemove(virConnectPtr conn, if (freecb) (*freecb)(cbList->callbacks[i]->opaque); virObjectUnref(cbList->callbacks[i]->conn); + if (cbList->callbacks[i]->dom) + VIR_FREE(cbList->callbacks[i]->dom->name); + VIR_FREE(cbList->callbacks[i]->dom); VIR_FREE(cbList->callbacks[i]); if (i < (cbList->count - 1)) @@ -225,6 +228,9 @@ virDomainEventCallbackListRemoveID(virConnectPtr conn, if (freecb) (*freecb)(cbList->callbacks[i]->opaque); virObjectUnref(cbList->callbacks[i]->conn); + if (cbList->callbacks[i]->dom) + VIR_FREE(cbList->callbacks[i]->dom->name); + VIR_FREE(cbList->callbacks[i]->dom); VIR_FREE(cbList->callbacks[i]); if (i < (cbList->count - 1)) |