[gimp] app: avoid risky alloca() in gimp_brush_save()



commit 24ed9dbdf5414864103e3433ffd0c58995696ecb
Author: Ell <ell_se yahoo com>
Date:   Thu Mar 28 16:52:08 2019 -0400

    app: avoid risky alloca() in gimp_brush_save()
    
    Replace an arbitrarily-sized g_alloca() with g_malloc() in
    gimp_brush_save().

 app/core/gimpbrush-save.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/app/core/gimpbrush-save.c b/app/core/gimpbrush-save.c
index 53202507ef..38d4bcd92f 100644
--- a/app/core/gimpbrush-save.c
+++ b/app/core/gimpbrush-save.c
@@ -68,7 +68,7 @@ gimp_brush_save (GimpData       *data,
   if (pixmap)
     {
       gsize   size = width * height * 4;
-      guchar *data = g_alloca (size);
+      guchar *data = g_malloc (size);
       guchar *p    = gimp_temp_buf_get_data (pixmap);
       guchar *m    = gimp_temp_buf_get_data (mask);
       guchar *d    = data;
@@ -85,9 +85,13 @@ gimp_brush_save (GimpData       *data,
       if (! g_output_stream_write_all (output, data, size,
                                        NULL, NULL, error))
         {
+          g_free (data);
+
           return FALSE;
         }
-     }
+
+      g_free (data);
+    }
   else
     {
       if (! g_output_stream_write_all (output,


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