[gimp] app: Fix corruption while in use of imported uri



commit 24ac01bfa92b0bdb94e13b7cc58e78e2be5fc6c7
Author: Mukund Sivaraman <muks banu com>
Date:   Sat May 7 05:51:30 2011 +0530

    app: Fix corruption while in use of imported uri

 app/actions/file-commands.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)
---
diff --git a/app/actions/file-commands.c b/app/actions/file-commands.c
index 2395e2e..581edf2 100644
--- a/app/actions/file-commands.c
+++ b/app/actions/file-commands.c
@@ -302,11 +302,21 @@ file_save_cmd_callback (GtkAction *action,
 
         if (uri && export_proc)
           {
+            char *uri_copy;
+
+            /* The memory that 'uri' points to can be freed by
+               file_save_dialog_save_image(), when it eventually calls
+               gimp_image_set_imported_uri() to reset the imported uri,
+               resulting in garbage. So make a duplicate of it here. */
+
+            uri_copy = g_strdup (uri);
+
             saved = file_save_dialog_save_image (GIMP_PROGRESS (display),
-                                                 gimp, image, uri,
+                                                 gimp, image, uri_copy,
                                                  export_proc,
                                                  GIMP_RUN_WITH_LAST_VALS,
                                                  FALSE, TRUE, TRUE);
+            g_free (uri_copy);
           }
       }
       break;



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