[gtk+/gtk-2-16] Avoid memory corruption on complicated confirm-overwrite logic



commit 35ab9b798387419d68a71fb9b5e476a5e4a83120
Author: Martin Nordholts <martinn src gnome org>
Date:   Fri May 15 21:29:25 2009 +0200

    Avoid memory corruption on complicated confirm-overwrite logic
    
    Dup the file chooser entry string because the string may be modified
    depending on what clients do in the confirm-overwrite signal and this
    corrupts the pointer.
---
 gtk/gtkfilechooserdefault.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/gtk/gtkfilechooserdefault.c b/gtk/gtkfilechooserdefault.c
index b70af42..5f40411 100644
--- a/gtk/gtkfilechooserdefault.c
+++ b/gtk/gtkfilechooserdefault.c
@@ -8307,10 +8307,15 @@ save_entry_get_info_cb (GCancellable *cancellable,
           if (data->file_exists_and_is_not_folder)
 	    {
 	      gboolean retval;
-	      const char *file_part;
+	      char *file_part;
 
-	      file_part = _gtk_file_chooser_entry_get_file_part (GTK_FILE_CHOOSER_ENTRY (data->impl->location_entry));
+              /* Dup the string because the string may be modified
+               * depending on what clients do in the confirm-overwrite
+               * signal and this corrupts the pointer
+               */
+              file_part = g_strdup (_gtk_file_chooser_entry_get_file_part (GTK_FILE_CHOOSER_ENTRY (data->impl->location_entry)));
 	      retval = should_respond_after_confirm_overwrite (data->impl, file_part, data->parent_file);
+              g_free (file_part);
 
 	      if (retval)
 		g_signal_emit_by_name (data->impl, "response-requested");



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