After 6b770f9a3bdabb1 both @netsource and @srcprops are leaked because of early return introduced in the commit. ==1812== 644 bytes in 4 blocks are definitely lost in loss record 835 of 885 ==1812== at 0x4C2F12F: realloc (vg_replace_malloc.c:785) ==1812== by 0x8846393: xmlSaveUriRealloc (in /usr/lib64/libxml2.so.2.9.8) ==1812== by 0x8846B1C: xmlSaveUri (in /usr/lib64/libxml2.so.2.9.8) ==1812== by 0x5DDA619: virURIFormat (viruri.c:256) ==1812== by 0x56E941B: qemuBuildNetworkDriveURI (qemu_command.c:781) ==1812== by 0x56E979A: qemuBuildNetworkDriveStr (qemu_command.c:859) ==1812== by 0x56F3A0B: qemuBuildSCSIiSCSIHostdevDrvStr (qemu_command.c:4664) ==1812== by 0x56F3D1F: qemuBuildSCSIHostdevDrvStr (qemu_command.c:4732) ==1812== by 0x56F57F7: qemuBuildHostdevCommandLine (qemu_command.c:5337) ==1812== by 0x570303A: qemuBuildCommandLine (qemu_command.c:10376) ==1812== by 0x57604EE: qemuProcessCreatePretendCmd (qemu_process.c:6649) ==1812== by 0x11352A: testCompareXMLToArgv (qemuxml2argvtest.c:566) Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx> --- src/qemu/qemu_command.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 32eb59b6ab..86970f3d91 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4644,8 +4644,8 @@ static char * qemuBuildSCSIiSCSIHostdevDrvStr(virDomainHostdevDefPtr dev, virQEMUCapsPtr qemuCaps) { + char *ret = NULL; virBuffer buf = VIR_BUFFER_INITIALIZER; - char *netsource = NULL; virJSONValuePtr srcprops = NULL; virDomainHostdevSubsysSCSIPtr scsisrc = &dev->source.subsys.u.scsi; @@ -4672,13 +4672,13 @@ qemuBuildSCSIiSCSIHostdevDrvStr(virDomainHostdevDefPtr dev, if (virBufferCheckError(&buf) < 0) goto cleanup; - return virBufferContentAndReset(&buf); + ret = virBufferContentAndReset(&buf); cleanup: VIR_FREE(netsource); virJSONValueFree(srcprops); virBufferFreeAndReset(&buf); - return NULL; + return ret; } char * -- 2.16.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list