diff --git a/ChangeLog b/ChangeLog index d2b16365a2..a6edb433f4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Mon Oct 25 16:49:19 PDT 1999 Manish Singh + + * app/gimpimage.c: don't free the old filename pointer till we're + all done, since we might be passed our own filename as a param + and reference it after freeing. The code didn't heed it's own + warning ;) (TigerT, this should fix that filename corruption bug) + 1999-10-25 Tor Lillqvist * app/cursorutil.h: Uncomment the inclusion of gdkcursor.h that diff --git a/app/core/gimpimage-guides.c b/app/core/gimpimage-guides.c index 1008d2e3b3..bb0739da30 100644 --- a/app/core/gimpimage-guides.c +++ b/app/core/gimpimage-guides.c @@ -318,7 +318,8 @@ void gimp_image_set_filename (GimpImage *gimage, gchar *filename) { - gchar *new_filename; + gchar *new_filename, *old_filename; + gboolean free_old; /* * WARNING: this function will free the current filename even if you are @@ -327,9 +328,8 @@ gimp_image_set_filename (GimpImage *gimage, */ new_filename = g_strdup (filename); - - if (gimage->has_filename) - g_free (gimage->filename); + old_filename = gimage->filename; + free_old = gimage->has_filename; if (filename && filename[0]) { @@ -342,6 +342,9 @@ gimp_image_set_filename (GimpImage *gimage, gimage->has_filename = FALSE; } + if (free_old) + g_free (old_filename); + gtk_signal_emit (GTK_OBJECT (gimage), gimp_image_signals[RENAME]); } diff --git a/app/core/gimpimage-merge.c b/app/core/gimpimage-merge.c index 1008d2e3b3..bb0739da30 100644 --- a/app/core/gimpimage-merge.c +++ b/app/core/gimpimage-merge.c @@ -318,7 +318,8 @@ void gimp_image_set_filename (GimpImage *gimage, gchar *filename) { - gchar *new_filename; + gchar *new_filename, *old_filename; + gboolean free_old; /* * WARNING: this function will free the current filename even if you are @@ -327,9 +328,8 @@ gimp_image_set_filename (GimpImage *gimage, */ new_filename = g_strdup (filename); - - if (gimage->has_filename) - g_free (gimage->filename); + old_filename = gimage->filename; + free_old = gimage->has_filename; if (filename && filename[0]) { @@ -342,6 +342,9 @@ gimp_image_set_filename (GimpImage *gimage, gimage->has_filename = FALSE; } + if (free_old) + g_free (old_filename); + gtk_signal_emit (GTK_OBJECT (gimage), gimp_image_signals[RENAME]); } diff --git a/app/core/gimpimage-projection.c b/app/core/gimpimage-projection.c index 1008d2e3b3..bb0739da30 100644 --- a/app/core/gimpimage-projection.c +++ b/app/core/gimpimage-projection.c @@ -318,7 +318,8 @@ void gimp_image_set_filename (GimpImage *gimage, gchar *filename) { - gchar *new_filename; + gchar *new_filename, *old_filename; + gboolean free_old; /* * WARNING: this function will free the current filename even if you are @@ -327,9 +328,8 @@ gimp_image_set_filename (GimpImage *gimage, */ new_filename = g_strdup (filename); - - if (gimage->has_filename) - g_free (gimage->filename); + old_filename = gimage->filename; + free_old = gimage->has_filename; if (filename && filename[0]) { @@ -342,6 +342,9 @@ gimp_image_set_filename (GimpImage *gimage, gimage->has_filename = FALSE; } + if (free_old) + g_free (old_filename); + gtk_signal_emit (GTK_OBJECT (gimage), gimp_image_signals[RENAME]); } diff --git a/app/core/gimpimage-resize.c b/app/core/gimpimage-resize.c index 1008d2e3b3..bb0739da30 100644 --- a/app/core/gimpimage-resize.c +++ b/app/core/gimpimage-resize.c @@ -318,7 +318,8 @@ void gimp_image_set_filename (GimpImage *gimage, gchar *filename) { - gchar *new_filename; + gchar *new_filename, *old_filename; + gboolean free_old; /* * WARNING: this function will free the current filename even if you are @@ -327,9 +328,8 @@ gimp_image_set_filename (GimpImage *gimage, */ new_filename = g_strdup (filename); - - if (gimage->has_filename) - g_free (gimage->filename); + old_filename = gimage->filename; + free_old = gimage->has_filename; if (filename && filename[0]) { @@ -342,6 +342,9 @@ gimp_image_set_filename (GimpImage *gimage, gimage->has_filename = FALSE; } + if (free_old) + g_free (old_filename); + gtk_signal_emit (GTK_OBJECT (gimage), gimp_image_signals[RENAME]); } diff --git a/app/core/gimpimage-scale.c b/app/core/gimpimage-scale.c index 1008d2e3b3..bb0739da30 100644 --- a/app/core/gimpimage-scale.c +++ b/app/core/gimpimage-scale.c @@ -318,7 +318,8 @@ void gimp_image_set_filename (GimpImage *gimage, gchar *filename) { - gchar *new_filename; + gchar *new_filename, *old_filename; + gboolean free_old; /* * WARNING: this function will free the current filename even if you are @@ -327,9 +328,8 @@ gimp_image_set_filename (GimpImage *gimage, */ new_filename = g_strdup (filename); - - if (gimage->has_filename) - g_free (gimage->filename); + old_filename = gimage->filename; + free_old = gimage->has_filename; if (filename && filename[0]) { @@ -342,6 +342,9 @@ gimp_image_set_filename (GimpImage *gimage, gimage->has_filename = FALSE; } + if (free_old) + g_free (old_filename); + gtk_signal_emit (GTK_OBJECT (gimage), gimp_image_signals[RENAME]); } diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c index 1008d2e3b3..bb0739da30 100644 --- a/app/core/gimpimage.c +++ b/app/core/gimpimage.c @@ -318,7 +318,8 @@ void gimp_image_set_filename (GimpImage *gimage, gchar *filename) { - gchar *new_filename; + gchar *new_filename, *old_filename; + gboolean free_old; /* * WARNING: this function will free the current filename even if you are @@ -327,9 +328,8 @@ gimp_image_set_filename (GimpImage *gimage, */ new_filename = g_strdup (filename); - - if (gimage->has_filename) - g_free (gimage->filename); + old_filename = gimage->filename; + free_old = gimage->has_filename; if (filename && filename[0]) { @@ -342,6 +342,9 @@ gimp_image_set_filename (GimpImage *gimage, gimage->has_filename = FALSE; } + if (free_old) + g_free (old_filename); + gtk_signal_emit (GTK_OBJECT (gimage), gimp_image_signals[RENAME]); } diff --git a/app/core/gimpprojection-construct.c b/app/core/gimpprojection-construct.c index 1008d2e3b3..bb0739da30 100644 --- a/app/core/gimpprojection-construct.c +++ b/app/core/gimpprojection-construct.c @@ -318,7 +318,8 @@ void gimp_image_set_filename (GimpImage *gimage, gchar *filename) { - gchar *new_filename; + gchar *new_filename, *old_filename; + gboolean free_old; /* * WARNING: this function will free the current filename even if you are @@ -327,9 +328,8 @@ gimp_image_set_filename (GimpImage *gimage, */ new_filename = g_strdup (filename); - - if (gimage->has_filename) - g_free (gimage->filename); + old_filename = gimage->filename; + free_old = gimage->has_filename; if (filename && filename[0]) { @@ -342,6 +342,9 @@ gimp_image_set_filename (GimpImage *gimage, gimage->has_filename = FALSE; } + if (free_old) + g_free (old_filename); + gtk_signal_emit (GTK_OBJECT (gimage), gimp_image_signals[RENAME]); } diff --git a/app/gimpimage.c b/app/gimpimage.c index 1008d2e3b3..bb0739da30 100644 --- a/app/gimpimage.c +++ b/app/gimpimage.c @@ -318,7 +318,8 @@ void gimp_image_set_filename (GimpImage *gimage, gchar *filename) { - gchar *new_filename; + gchar *new_filename, *old_filename; + gboolean free_old; /* * WARNING: this function will free the current filename even if you are @@ -327,9 +328,8 @@ gimp_image_set_filename (GimpImage *gimage, */ new_filename = g_strdup (filename); - - if (gimage->has_filename) - g_free (gimage->filename); + old_filename = gimage->filename; + free_old = gimage->has_filename; if (filename && filename[0]) { @@ -342,6 +342,9 @@ gimp_image_set_filename (GimpImage *gimage, gimage->has_filename = FALSE; } + if (free_old) + g_free (old_filename); + gtk_signal_emit (GTK_OBJECT (gimage), gimp_image_signals[RENAME]); }