]> git.ipfire.org Git - thirdparty/libvirt.git/commit
bhyve_command: Avoid leaking @buf in virBhyveProcessBuildBhyveCmd()
authorMichal Privoznik <mprivozn@redhat.com>
Mon, 2 Feb 2026 15:26:06 +0000 (16:26 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 4 Feb 2026 07:29:38 +0000 (08:29 +0100)
commitdf2cb810a3fc5929833f150de7512546d5891728
tree7f8b0a450b68cb1ff9cfd6c50eef4ffdbd3895c7
parent1ce8c35c29a0d8061d662195eacfb592c831f6dc
bhyve_command: Avoid leaking @buf in virBhyveProcessBuildBhyveCmd()

When building OS loader part of bhyve command line, there's @buf
declared and it is even correctly annotated with g_auto() to be
freed automatically. But then, the buffer contents is appended
onto the command line using virBufferContentAndReset() which
leads to a memleak because the buffer is reset. It's
virBufferCurrentContent() that should have been used instead.

128 bytes in 1 blocks are definitely lost in loss record 476 of 536
   at 0x48882B1: realloc (vg_replace_malloc.c:1810)
   by 0x4EE6622: g_realloc (in /usr/local/lib/libglib-2.0.so.0.8400.4)
   by 0x4F048BC: g_string_new (in /usr/local/lib/libglib-2.0.so.0.8400.4)
   by 0x4A59E1E: virBufferInitialize (virbuffer.c:121)
   by 0x4A5A63C: virBufferVasprintf (virbuffer.c:321)
   by 0x4A5A5DE: virBufferAsprintf (virbuffer.c:303)
   by 0x401B22F: virBhyveProcessBuildBhyveCmd (bhyve_command.c:1021)
   by 0x4015F05: testCompareXMLToArgvFiles (bhyvexml2argvtest.c:72)
   by 0x4015BA9: testCompareXMLToArgvHelper (bhyvexml2argvtest.c:144)
   by 0x4016588: virTestRun (testutils.c:143)
   by 0x4015919: mymain (bhyvexml2argvtest.c:341)
   by 0x4018882: virTestMain (testutils.c:913)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
src/bhyve/bhyve_command.c