From 24ed9dbdf5414864103e3433ffd0c58995696ecb Mon Sep 17 00:00:00 2001 From: Ell Date: Thu, 28 Mar 2019 16:52:08 -0400 Subject: [PATCH] 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,