]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
domain_event: Resolve memory leak found by Valgrind
authorJohn Ferlan <jferlan@redhat.com>
Tue, 23 Jul 2013 14:06:02 +0000 (10:06 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Tue, 23 Jul 2013 23:04:48 +0000 (19:04 -0400)
Commit id '4421e257' strdup'd devAlias, but didn't free

Running qemuhotplugtest under valgrind resulted in the following:

==7375== 9 bytes in 1 blocks are definitely lost in loss record 11 of 70
==7375==    at 0x4A0887C: malloc (vg_replace_malloc.c:270)
==7375==    by 0x37C1085D71: strdup (strdup.c:42)
==7375==    by 0x4CBBD5F: virStrdup (virstring.c:554)
==7375==    by 0x4CFF9CB: virDomainEventDeviceRemovedNew (domain_event.c:1174)
==7375==    by 0x427791: qemuDomainRemoveChrDevice (qemu_hotplug.c:2508)
==7375==    by 0x42C65D: qemuDomainDetachChrDevice (qemu_hotplug.c:3357)
==7375==    by 0x41C94F: testQemuHotplug (qemuhotplugtest.c:115)
==7375==    by 0x41D817: virtTestRun (testutils.c:168)
==7375==    by 0x41C400: mymain (qemuhotplugtest.c:322)
==7375==    by 0x41DF3A: virtTestMain (testutils.c:764)
==7375==    by 0x37C1021A04: (below main) (libc-start.c:225)

src/conf/domain_event.c

index 640463c25844a5564065faf44eaaa134a101ba1c..16ae92b49f10e608572df1813ead63e887e296a0 100644 (file)
@@ -520,6 +520,9 @@ void virDomainEventFree(virDomainEventPtr event)
     case VIR_DOMAIN_EVENT_ID_TRAY_CHANGE:
         VIR_FREE(event->data.trayChange.devAlias);
         break;
+    case VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED:
+        VIR_FREE(event->data.deviceRemoved.devAlias);
+        break;
     }
 
     VIR_FREE(event->dom.name);