[gimp/gimp-2-10] Issue #1974: Memory leak in gimpimage.c.



commit 71f37d417c306b4fdb53daf0cb6a439e63819f98
Author: Jehan <jehan girinstud io>
Date:   Sat Aug 4 12:54:07 2018 +0200

    Issue #1974: Memory leak in gimpimage.c.
    
    Ok my previous fix was wrong (at least for the part in the macro). This
    is a macro, not a function. So each time we write _reason, the call to
    g_strdup_printf() is reevaluated, hence data is allocated.
    The right fix is to prepend `tmp` to the list, not `_reason`.
    Thanks to Massimo for the debugging, as always!
    
    (cherry picked from commit 2912fe7c1765dfc8d2e3f4858dc03ef4178e1c70)

 app/core/gimpimage.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
---
diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c
index 101fe20bb3..e0aaf332ab 100644
--- a/app/core/gimpimage.c
+++ b/app/core/gimpimage.c
@@ -2357,8 +2357,7 @@ 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)); }            \
-  else g_free (_reason);
+      reasons = g_list_prepend (reasons, tmp); }
 
   /* need version 1 for colormaps */
   if (gimp_image_get_colormap (image))


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]