mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-11-12 13:52:55 +01:00
gutils: Fix deliberate-leak code in g_reload_user_special_dirs_cache()
It seems it wasn’t behaving as advertised: it was freeing all the old string values unless they were strcmp-equal to the new ones, in which case the new ones were discarded. What’s actually documented is that the old values are always leaked, unless they’re strcmp-equal to the new ones. Adjust the code to match the documentation. A unit test will be added in a following commit. Signed-off-by: Philip Withnall <pwithnall@gnome.org>
This commit is contained in:
@@ -2337,18 +2337,18 @@ g_reload_user_special_dirs_cache (void)
|
||||
for (i = 0; i < G_USER_N_DIRECTORIES; i++)
|
||||
{
|
||||
old_val = old_g_user_special_dirs[i];
|
||||
if (g_user_special_dirs[i] == NULL)
|
||||
|
||||
if (g_user_special_dirs[i] == NULL ||
|
||||
g_strcmp0 (old_val, g_user_special_dirs[i]) != 0)
|
||||
{
|
||||
g_user_special_dirs[i] = old_val;
|
||||
g_ignore_leak (old_val);
|
||||
}
|
||||
else if (g_strcmp0 (old_val, g_user_special_dirs[i]) == 0)
|
||||
else
|
||||
{
|
||||
/* don't leak */
|
||||
g_free (g_user_special_dirs[i]);
|
||||
g_user_special_dirs[i] = old_val;
|
||||
}
|
||||
else
|
||||
g_free (old_val);
|
||||
}
|
||||
|
||||
/* free the old array */
|
||||
|
||||
Reference in New Issue
Block a user