From 9102ab4230cb0e25c1e87128d5eb4051b8caa83a Mon Sep 17 00:00:00 2001 From: gaobo-kylinsec Date: Thu, 23 Apr 2026 11:23:21 +0800 Subject: [PATCH 1/4] emblem-sidebar: fix memory leak of popup menu widget Destroy popup menu in finalize function since it's a floating widget without parent. Also nullify borrowed pointers to avoid dangling references. --- src/caja-emblem-sidebar.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/caja-emblem-sidebar.c b/src/caja-emblem-sidebar.c index f6fc6860e..9c46837e6 100644 --- a/src/caja-emblem-sidebar.c +++ b/src/caja-emblem-sidebar.c @@ -360,6 +360,10 @@ create_popup_menu (CajaEmblemSidebar *emblem_sidebar) popup = gtk_menu_new (); + gtk_menu_attach_to_widget (GTK_MENU (popup), + GTK_WIDGET (emblem_sidebar), + NULL); + gtk_menu_set_reserve_toggle_size (GTK_MENU (popup), FALSE); /* add the "rename" menu item */ From 4fa518001bc85d01f1de6f36596b39e35783cf95 Mon Sep 17 00:00:00 2001 From: gaobo-kylinsec Date: Thu, 23 Apr 2026 18:44:46 +0800 Subject: [PATCH 2/4] icon-info: fix cache key mismatch for loadable icons The lookup key used size * scale while the insert key used original size, causing cache misses and unbounded cache growth. --- libcaja-private/caja-icon-info.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libcaja-private/caja-icon-info.c b/libcaja-private/caja-icon-info.c index 02ce1d8a9..a681c0166 100644 --- a/libcaja-private/caja-icon-info.c +++ b/libcaja-private/caja-icon-info.c @@ -347,7 +347,7 @@ caja_icon_info_lookup (GIcon *icon, lookup_key.icon = icon; lookup_key.scale = scale; - lookup_key.size = size * scale; + lookup_key.size = size; icon_info = g_hash_table_lookup (loadable_icon_cache, &lookup_key); if (icon_info) From bc5cf510b74a0efc45c0745290f78ee0d9702242 Mon Sep 17 00:00:00 2001 From: gaobo-kylinsec Date: Thu, 23 Apr 2026 19:46:07 +0800 Subject: [PATCH 3/4] notes-viewer: fix memory leak of text buffer Valgrind shows: ==2022== 40,416 bytes in 1,010 blocks are still reachable in loss record 1,771 of 1,825 ==2022== at 0x877258A: g_type_create_instance (in /usr/lib64/libgobject-2.0.so.0.5600.1) ==2022== by 0x87561FC: ??? (in /usr/lib64/libgobject-2.0.so.0.5600.1) ==2022== by 0x8758120: g_object_new_valist (in /usr/lib64/libgobject-2.0.so.0.5600.1) ==2022== by 0x8758468: g_object_new (in /usr/lib64/libgobject-2.0.so.0.5600.1) ==2022== by 0x468B2C: caja_notes_viewer_init (caja-notes-viewer.c:339) gtk_text_view_new_with_buffer() adds a reference to the text buffer, so we need to unref it after to transfer ownership. --- src/caja-notes-viewer.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/caja-notes-viewer.c b/src/caja-notes-viewer.c index 10f03e0b0..d65916644 100644 --- a/src/caja-notes-viewer.c +++ b/src/caja-notes-viewer.c @@ -338,6 +338,8 @@ caja_notes_viewer_init (CajaNotesViewer *sidebar) /* create the text container */ details->text_buffer = gtk_text_buffer_new (NULL); details->note_text_field = gtk_text_view_new_with_buffer (details->text_buffer); + // gtk_text_view_new_with_buffer will add reference to text buffer + g_object_unref (details->text_buffer); gtk_text_view_set_editable (GTK_TEXT_VIEW (details->note_text_field), TRUE); gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (details->note_text_field), From da3f8651ed52c996e7413d8117b960d8bf0a4aab Mon Sep 17 00:00:00 2001 From: gaobo-kylinsec Date: Thu, 23 Apr 2026 19:53:59 +0800 Subject: [PATCH 4/4] 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(+) diff --git a/src/caja-window-menus.c b/src/caja-window-menus.c index 3b65fa79a..babbe108e 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); } }