render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
6ae9ed
From 6add0a541a003a6ba45ddf5aa7412e2ded98dcac Mon Sep 17 00:00:00 2001
6ae9ed
Message-Id: <6add0a541a003a6ba45ddf5aa7412e2ded98dcac@dist-git>
6ae9ed
From: Michal Privoznik <mprivozn@redhat.com>
6ae9ed
Date: Wed, 24 Aug 2016 16:10:57 -0400
6ae9ed
Subject: [PATCH] qemuBuildCpuCommandLine: Don't leak @buf
6ae9ed
6ae9ed
https://bugzilla.redhat.com/show_bug.cgi?id=1097930
6ae9ed
https://bugzilla.redhat.com/show_bug.cgi?id=1224341
6ae9ed
6ae9ed
Just like every other qemuBuild*CommandLine() function, this uses
6ae9ed
a buffer to hold partial cmd line strings too. However, if
6ae9ed
there's an error, the control jumps to 'cleanup' label leaving
6ae9ed
the buffer behind and thus leaking it.
6ae9ed
6ae9ed
==2013== 1,006 bytes in 1 blocks are definitely lost in loss record 701 of 711
6ae9ed
==2013==    at 0x4C29F80: malloc (vg_replace_malloc.c:296)
6ae9ed
==2013==    by 0x4C2C32F: realloc (vg_replace_malloc.c:692)
6ae9ed
==2013==    by 0xAD925A8: virReallocN (viralloc.c:245)
6ae9ed
==2013==    by 0xAD95EA8: virBufferGrow (virbuffer.c:130)
6ae9ed
==2013==    by 0xAD95F78: virBufferAdd (virbuffer.c:165)
6ae9ed
==2013==    by 0x5097F5: qemuBuildCpuModelArgStr (qemu_command.c:6339)
6ae9ed
==2013==    by 0x509CC3: qemuBuildCpuCommandLine (qemu_command.c:6437)
6ae9ed
==2013==    by 0x51142C: qemuBuildCommandLine (qemu_command.c:9174)
6ae9ed
==2013==    by 0x47CA3A: qemuProcessCreatePretendCmd (qemu_process.c:5546)
6ae9ed
==2013==    by 0x433698: testCompareXMLToArgvFiles (qemuxml2argvtest.c:332)
6ae9ed
==2013==    by 0x4339AC: testCompareXMLToArgvHelper (qemuxml2argvtest.c:413)
6ae9ed
==2013==    by 0x446E7A: virTestRun (testutils.c:179)
6ae9ed
6ae9ed
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
6ae9ed
(cherry picked from commit 87df945240dcd9769d6fd6dbddfb2bb5601b349d)
6ae9ed
---
6ae9ed
 src/qemu/qemu_command.c | 1 +
6ae9ed
 1 file changed, 1 insertion(+)
6ae9ed
6ae9ed
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
6ae9ed
index 9832a6a..57b04ee 100644
6ae9ed
--- a/src/qemu/qemu_command.c
6ae9ed
+++ b/src/qemu/qemu_command.c
6ae9ed
@@ -6841,6 +6841,7 @@ qemuBuildCpuCommandLine(virCommandPtr cmd,
6ae9ed
 
6ae9ed
  cleanup:
6ae9ed
     VIR_FREE(cpu);
6ae9ed
+    virBufferFreeAndReset(&buf;;
6ae9ed
     return ret;
6ae9ed
 }
6ae9ed
 
6ae9ed
-- 
6ae9ed
2.10.0
6ae9ed