Skip to content

Fix XfceRc leak in garcon_menu_directory_new

Description

This leak would occur when a .desktop file was missing a name entry.

Leak report

Direct leak of 368 byte(s) in 2 object(s) allocated from:
    #0 0x7fbb5e17335d in calloc
    #1 0x7fbb5dd97dba in g_malloc0 glib/glib/gmem.c:133:13
    #2 0x7fbb5ec50448 in _xfce_rc_simple_new libxfce4util/libxfce4util/xfce-rc-simple.c:589:12
    #3 0x7fbb5ec59f0d in xfce_rc_simple_open libxfce4util/libxfce4util/xfce-rc.c:145:12
    #4 0x7fbb5619163f in garcon_menu_directory_new garcon/garcon/garcon-menu-directory.c:352:8
    #5 0x7fbb561c2d50 in garcon_menu_lookup_directory garcon/garcon/garcon-menu.c:1068:23
    #6 0x7fbb561c2d50 in garcon_menu_resolve_directory garcon/garcon/garcon-menu.c:1002:19
    #7 0x7fbb561d294d in garcon_menu_directory_file_changed garcon/garcon/garcon-menu.c:2512:7
[...snip...]

Steps to reproduce

I'm not sure how I initially triggered this leak because all of my .desktop files seem to have name entries. To test the patch, I used this change:

diff --git a/garcon/garcon-menu-directory.c b/garcon/garcon-menu-directory.c
index 0b8db4a..4113724 100644
--- a/garcon/garcon-menu-directory.c
+++ b/garcon/garcon-menu-directory.c
@@ -357,11 +357,14 @@ garcon_menu_directory_new (GFile *file)
   xfce_rc_set_group (rc, G_KEY_FILE_DESKTOP_GROUP);
 
   /* Parse name, exec command and icon name */
-  name = xfce_rc_read_entry (rc, G_KEY_FILE_DESKTOP_KEY_NAME, NULL);
+  name = xfce_rc_read_entry (rc, G_KEY_FILE_DESKTOP_KEY_GENERIC_NAME, NULL);

Testing

  • No issues were detected when testing the patch with UBSan, LSan, and ASan

Merge request reports

Loading