mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-20 06:50:22 +03:00
Fix memory leak in qemuBuildDriveStr()
This patch fixes memory leaks reported by valgrind on running qemuxml2argvtest; introduced in commit 0df53f04. Most of them are of the form: ==24777== 15 bytes in 1 blocks are definitely lost in loss record 39 of 129 ==24777== at 0x4A0887C: malloc (vg_replace_malloc.c:270) ==24777== by 0x341F485E21: strdup (strdup.c:42) ==24777== by 0x4CADE5F: virStrdup (virstring.c:554) ==24777== by 0x4362B6: qemuBuildDriveStr (qemu_command.c:3848) ==24777== by 0x43EF73: qemuBuildCommandLine (qemu_command.c:8500) ==24777== by 0x426670: testCompareXMLToArgvHelper (qemuxml2argvtest.c:350) ==24777== by 0x427C01: virtTestRun (testutils.c:138) ==24777== by 0x41DDB5: mymain (qemuxml2argvtest.c:658) ==24777== by 0x4282A2: virtTestMain (testutils.c:593) ==24777== by 0x341F421A04: (below main) (libc-start.c:225) ==24777== Signed-off-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
df36af589f
commit
f386d323e6
@ -4063,6 +4063,7 @@ qemuBuildDriveStr(virConnectPtr conn,
|
||||
|
||||
virBufferEscape(&opt, ',', ",", "%s,", source);
|
||||
}
|
||||
VIR_FREE(source);
|
||||
|
||||
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE))
|
||||
virBufferAddLit(&opt, "if=none");
|
||||
@ -4274,6 +4275,7 @@ qemuBuildDriveStr(virConnectPtr conn,
|
||||
return virBufferContentAndReset(&opt);
|
||||
|
||||
error:
|
||||
VIR_FREE(source);
|
||||
virBufferFreeAndReset(&opt);
|
||||
return NULL;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user