Skip to content

Potential memory leak in xfdesktop-file-utils.c

Hello!

In xfdesktop-file-utils.c we create two uri arrays source_uris and target_uris at https://gitlab.xfce.org/xfce/xfdesktop/-/blob/master/src/xfdesktop-file-utils.c#L1483

        gchar **source_uris = xfdesktop_file_utils_file_list_to_uri_array(source_files);
        gchar **target_uris = xfdesktop_file_utils_file_list_to_uri_array(target_files);

Then at https://gitlab.xfce.org/xfce/xfdesktop/-/blob/master/src/xfdesktop-file-utils.c#L1531 we free target_uris[0] and source_uris[0]:

        g_free(target_uris[0]);
        g_free(source_uris[0]);

Why to just free the first members and not the complete source_uris and target_uris uri arrays like this?

        g_strfreev(target_uris);
        g_strfreev(source_uris);

If this is indeed a bug then I can open a MR proposing the fix. (I'm not sure as I don't understand what g_dbus_proxy_call_sync() does exactly)

Thanks!

Found by: scan-build

Edited by Avinash Sonawane