Commit 8909684b authored by Jehan's avatar Jehan

Issue #1974: Memory leak in gimpimage.c.

ADD_REASON macro was leaking the allocated string when version_reason
return value was NULL (i.e. when we didn't care about the version
reasons).

Also we were not properly freeing all the reason strings at the end,
only the list. Use g_list_free_full() instead of g_list_free().

(cherry picked from commit 0ab682b0)
parent 53b07a92
......@@ -2357,7 +2357,8 @@ gimp_image_get_xcf_version (GimpImage *image,
if (g_list_find_custom (reasons, tmp, (GCompareFunc) strcmp)) \
g_free (tmp); \
else \
reasons = g_list_prepend (reasons, (_reason)); }
reasons = g_list_prepend (reasons, (_reason)); } \
else g_free (_reason);
/* need version 1 for colormaps */
if (gimp_image_get_colormap (image))
......@@ -2570,10 +2571,10 @@ gimp_image_get_xcf_version (GimpImage *image,
g_string_append_c (reason, '\n');
}
g_list_free (reasons);
*version_reason = g_string_free (reason, FALSE);
}
if (reasons)
g_list_free_full (reasons, g_free);
return version;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment