From cefff5f07f172f3a4f67eb653282fe48769d84e2 Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Fri, 16 Mar 2007 14:24:02 +0000 Subject: [PATCH] don't just g_free() the GValueArray after we memcpy()-stole its values 2007-03-16 Michael Natterer * app/plug-in/gimppluginprocframe.c (gimp_plug_in_proc_frame_get_return_vals): don't just g_free() the GValueArray after we memcpy()-stole its values because this both leaks the contained array of GValues and crashes with glib trunk where GValueArray is slice-allocated. Instead, free the array of GValues manually, set it to NULL and use g_value_array_free(). svn path=/trunk/; revision=22134 --- ChangeLog | 9 +++++++++ app/plug-in/gimppluginprocframe.c | 13 ++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 25690b9d72..38b4120529 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2007-03-16 Michael Natterer + + * app/plug-in/gimppluginprocframe.c + (gimp_plug_in_proc_frame_get_return_vals): don't just g_free() the + GValueArray after we memcpy()-stole its values because this both + leaks the contained array of GValues and crashes with glib trunk + where GValueArray is slice-allocated. Instead, free the array of + GValues manually, set it to NULL and use g_value_array_free(). + 2007-03-16 Michael Natterer * plug-ins/script-fu/script-fu.c: remove N_() from calls to diff --git a/app/plug-in/gimppluginprocframe.c b/app/plug-in/gimppluginprocframe.c index a8ab7d5333..b4ae138344 100644 --- a/app/plug-in/gimppluginprocframe.c +++ b/app/plug-in/gimppluginprocframe.c @@ -179,9 +179,15 @@ gimp_plug_in_proc_frame_get_return_vals (GimpPlugInProcFrame *proc_frame) memcpy (return_vals->values, proc_frame->return_vals->values, sizeof (GValue) * proc_frame->return_vals->n_values); - /* Free the old argument pointer. */ - g_free (proc_frame->return_vals); + /* Free the old arguments. */ + g_free (proc_frame->return_vals->values); + proc_frame->return_vals->values = 0; + proc_frame->return_vals->n_values = 0; + g_value_array_free (proc_frame->return_vals); } + + /* We have consumed any saved values, so clear them. */ + proc_frame->return_vals = NULL; } else { @@ -190,8 +196,5 @@ gimp_plug_in_proc_frame_get_return_vals (GimpPlugInProcFrame *proc_frame) FALSE); } - /* We have consumed any saved values, so clear them. */ - proc_frame->return_vals = NULL; - return return_vals; }