]> git.ipfire.org Git - thirdparty/libvirt.git/commit
ch: Avoid memleak in virCHDriverConfigDispose()
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 9 Sep 2025 15:10:56 +0000 (17:10 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 10 Sep 2025 07:56:50 +0000 (09:56 +0200)
commit20d5c61cb47a0c83e8b3928dcd9c3d8c9778873f
tree9ac7942aa1cbd4c78c32c06f989f4636fdc4da7d
parentf35a1def9d7543e10f60ba3af847321d2a218b3e
ch: Avoid memleak in virCHDriverConfigDispose()

When virCHDriverConfig struct is initialized in
virCHDriverConfigNew() the 'configDir' member is allocated but
corresponding free is missing in virCHDriverConfigDispose().
While at it, reorder the free calls to match the order in which
they are declared in the struct so it's easier to spot missing
free call.

20 bytes in 1 blocks are definitely lost in loss record 667 of 2,033
   at 0x4912888: malloc (vg_replace_malloc.c:446)
   by 0x5436747: __vasprintf_internal (in /usr/lib64/libc.so.6)
   by 0x503EC81: g_vasprintf (in /usr/lib64/libglib-2.0.so.0.8400.3)
   by 0x500805B: g_strdup_vprintf (in /usr/lib64/libglib-2.0.so.0.8400.3)
   by 0x5008124: g_strdup_printf (in /usr/lib64/libglib-2.0.so.0.8400.3)
   by 0xB8C2B70: virCHDriverConfigNew (ch_conf.c:181)
   by 0xB8C9DDA: chStateInitialize (ch_driver.c:1456)
   by 0x4D9E316: virStateInitialize (libvirt.c:667)
   by 0x40539DB: daemonRunStateInit (remote_daemon.c:581)
   by 0x4AC1EB4: virThreadHelper (virthread.c:256)
   by 0x5441DE3: start_thread (in /usr/lib64/libc.so.6)
   by 0x54C25F3: clone (in /usr/lib64/libc.so.6)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
src/ch/ch_conf.c