mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 19:32:19 +00:00
qemu: Avoid memory leaks on qemuParseRBDString
Detected by valgrind. Leak introduced in commit 5745dc1. * src/qemu/qemu_command.c: fix memory leak on failure and successful path. * How to reproduce? % valgrind -v --leak-check=full ./qemuargv2xmltest * Actual result: ==2196== 80 bytes in 1 blocks are definitely lost in loss record 3 of 4 ==2196== at 0x4A05FDE: malloc (vg_replace_malloc.c:236) ==2196== by 0x39CF07F6E1: strdup (in /lib64/libc-2.12.so) ==2196== by 0x419823: qemuParseRBDString (qemu_command.c:1657) ==2196== by 0x4221ED: qemuParseCommandLine (qemu_command.c:5934) ==2196== by 0x422AFB: qemuParseCommandLineString (qemu_command.c:7561) ==2196== by 0x416864: testCompareXMLToArgvHelper (qemuargv2xmltest.c:48) ==2196== by 0x417DB1: virtTestRun (testutils.c:141) ==2196== by 0x415CAF: mymain (qemuargv2xmltest.c:175) ==2196== by 0x4174A7: virtTestMain (testutils.c:696) ==2196== by 0x39CF01ECDC: (below main) (in /lib64/libc-2.12.so) ==2196== ==2196== LEAK SUMMARY: ==2196== definitely lost: 80 bytes in 1 blocks Signed-off-by: Alex Jia <ajia@redhat.com>
This commit is contained in:
parent
307f363509
commit
b41d440e61
@ -1709,9 +1709,11 @@ static int qemuParseRBDString(virDomainDiskDefPtr disk)
|
||||
|
||||
p = next;
|
||||
}
|
||||
VIR_FREE(options);
|
||||
return 0;
|
||||
|
||||
no_memory:
|
||||
VIR_FREE(options);
|
||||
virReportOOMError();
|
||||
return -1;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user