From: Michal Privoznik Date: Tue, 9 Sep 2025 15:10:56 +0000 (+0200) Subject: ch: Avoid memleak in virCHDriverConfigDispose() X-Git-Tag: v11.8.0-rc1~54 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=20d5c61cb47a0c83e8b3928dcd9c3d8c9778873f;p=thirdparty%2Flibvirt.git 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 Reviewed-by: Peter Krempa --- diff --git a/src/ch/ch_conf.c b/src/ch/ch_conf.c index b9432e2a42..8a542eef19 100644 --- a/src/ch/ch_conf.c +++ b/src/ch/ch_conf.c @@ -211,9 +211,10 @@ virCHDriverConfigDispose(void *obj) { virCHDriverConfig *cfg = obj; - g_free(cfg->saveDir); g_free(cfg->stateDir); + g_free(cfg->configDir); g_free(cfg->logDir); + g_free(cfg->saveDir); } #define MIN_VERSION ((15 * 1000000) + (0 * 1000) + (0))