From 5382d8fcdf08ac2c833858370ac0176158e37ffe Mon Sep 17 00:00:00 2001 From: gaobo-kylinsec Date: Thu, 23 Apr 2026 19:53:59 +0800 Subject: window-menus: fix memory leak of menu and action objects Valgrind shows: ==2022== 129,024 bytes in 504 blocks are still reachable in loss record 1,798 of 1,825 ==2022== at 0x4C29BC3: malloc (vg_replace_malloc.c:299) ==2022== by 0xDDD860A: ??? (in /usr/lib64/libpixman-1.so.0.34.0) ==2022== by 0xDD9F719: ??? (in /usr/lib64/libpixman-1.so.0.34.0) ==2022== by 0x797DF88: ??? (in /usr/lib64/libcairo.so.2.11512.0) ==2022== by 0x797EBE6: ??? (in /usr/lib64/libcairo.so.2.11512.0) ==2022== by 0x797EC7B: ??? (in /usr/lib64/libcairo.so.2.11512.0) ==2022== by 0x795224C: cairo_surface_create_similar_image (in /usr/lib64/libcairo.so.2.11512.0) ==2022== by 0x6B88AB0: gdk_window_create_similar_image_surface (in /usr/lib64/libgdk-3.so.0.2200.30) ==2022== by 0x6B61FDF: gdk_cairo_surface_create_from_pixbuf (in /usr/lib64/libgdk-3.so.0.2200.30) ==2022== by 0x5157D2: caja_icon_info_get_surface_nodefault_at_size (caja-icon-info.c:576) ==2022== by 0x52830A: get_action_icon (caja-ui-utilities.c:160) ==2022== by 0x528691: caja_action_from_menu_item (caja-ui-utilities.c:189) ==2022== by 0x4853EE: add_extension_menu_items (caja-window-menus.c:1097) ==2022== by 0x485DEC: caja_window_load_extension_menus (caja-window-menus.c:1174) gtk_action_group_add_action_with_accel() adds a reference to the action, so we need to unref it after. The menu object is obtained via g_object_get() which returns a full reference that must be unreleased. --- src/caja-window-menus.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/caja-window-menus.c b/src/caja-window-menus.c index 3b65fa79..babbe108 100644 --- a/src/caja-window-menus.c +++ b/src/caja-window-menus.c @@ -1165,7 +1165,11 @@ add_extension_menu_items (CajaWindow *window, caja_menu_item_list_free (children); g_free (subdir); + + g_object_unref (menu); } + + g_object_unref (action); } } -- cgit v1.2.1