]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemuBuildCpuCommandLine: Don't leak @buf
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 8 Jul 2016 16:17:35 +0000 (18:17 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 11 Jul 2016 12:21:01 +0000 (14:21 +0200)
Just like every other qemuBuild*CommandLine() function, this uses
a buffer to hold partial cmd line strings too. However, if
there's an error, the control jumps to 'cleanup' label leaving
the buffer behind and thus leaking it.

==2013== 1,006 bytes in 1 blocks are definitely lost in loss record 701 of 711
==2013==    at 0x4C29F80: malloc (vg_replace_malloc.c:296)
==2013==    by 0x4C2C32F: realloc (vg_replace_malloc.c:692)
==2013==    by 0xAD925A8: virReallocN (viralloc.c:245)
==2013==    by 0xAD95EA8: virBufferGrow (virbuffer.c:130)
==2013==    by 0xAD95F78: virBufferAdd (virbuffer.c:165)
==2013==    by 0x5097F5: qemuBuildCpuModelArgStr (qemu_command.c:6339)
==2013==    by 0x509CC3: qemuBuildCpuCommandLine (qemu_command.c:6437)
==2013==    by 0x51142C: qemuBuildCommandLine (qemu_command.c:9174)
==2013==    by 0x47CA3A: qemuProcessCreatePretendCmd (qemu_process.c:5546)
==2013==    by 0x433698: testCompareXMLToArgvFiles (qemuxml2argvtest.c:332)
==2013==    by 0x4339AC: testCompareXMLToArgvHelper (qemuxml2argvtest.c:413)
==2013==    by 0x446E7A: virTestRun (testutils.c:179)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_command.c

index 667691baf15fa1f70f05425fdf6528c49049c5d6..c97d0f68b7bc15912d69c3faa73f0c8ba48de896 100644 (file)
@@ -6604,6 +6604,7 @@ qemuBuildCpuCommandLine(virCommandPtr cmd,
 
  cleanup:
     VIR_FREE(cpu);
+    virBufferFreeAndReset(&buf);
     return ret;
 }