]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
bhyvexml2argvtest: Avoid leaking firmwareDir
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 3 Feb 2026 11:10:00 +0000 (12:10 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 4 Feb 2026 07:29:38 +0000 (08:29 +0100)
The firmwareDir member of driver config is set at the beginning
of mymain(). But then, roughly in the middle of test cases it is
overwritten to fakefirmwareemptydir. But this means the old value
must be freed. Or reassigned back to its original variable which
is freed automatically.

16 bytes in 1 blocks are definitely lost in loss record 190 of 505
   at 0x4883224: malloc (vg_replace_malloc.c:451)
   by 0x4EE6562: g_malloc (in /usr/local/lib/libglib-2.0.so.0.8400.4)
   by 0x4F0100F: g_strdup (in /usr/local/lib/libglib-2.0.so.0.8400.4)
   by 0x4013E26: g_strdup_inline (gstrfuncs.h:321)
   by 0x4013E26: mymain (bhyvexml2argvtest.c:151)
   by 0x40189A2: virTestMain (testutils.c:913)
   by 0x4013DE6: main (bhyvexml2argvtest.c:354)

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

index 8f078f9d787d600958bed37c849de708ecb9fcdd..ae43445cdef1d8dca43968fbd7c7185ad36667e7 100644 (file)
@@ -249,7 +249,8 @@ mymain(void)
     DO_TEST("isa-controller");
     DO_TEST_FAILURE("isa-multiple-controllers");
     DO_TEST("firmware-efi");
-    driver.config->firmwareDir = fakefirmwareemptydir;
+    fakefirmwaredir = g_steal_pointer(&driver.config->firmwareDir);
+    driver.config->firmwareDir = g_steal_pointer(&fakefirmwareemptydir);
     DO_TEST_PREPARE_ERROR("firmware-efi");
     DO_TEST("fs-9p");
     DO_TEST("fs-9p-readonly");