[gimp] Issue #2379 - Crash on saving



commit c55f2308e174439c08fe4992722934ea1b7ed2fa
Author: Michael Natterer <mitch gimp org>
Date:   Wed Oct 31 23:46:06 2018 +0100

    Issue #2379 - Crash on saving
    
    file_save(): make sure we always set an error on failure
    
    file_save_dialog_save_image(): additionally, check that "error" exists
    before dereferencing it.

 app/dialogs/file-save-dialog.c |  3 ++-
 app/file/file-save.c           | 14 ++++++++++++--
 2 files changed, 14 insertions(+), 3 deletions(-)
---
diff --git a/app/dialogs/file-save-dialog.c b/app/dialogs/file-save-dialog.c
index 150a4f902e..37714cd502 100644
--- a/app/dialogs/file-save-dialog.c
+++ b/app/dialogs/file-save-dialog.c
@@ -798,7 +798,8 @@ file_save_dialog_save_image (GimpProgress        *progress,
       {
         gimp_message (gimp, G_OBJECT (progress), GIMP_MESSAGE_ERROR,
                       _("Saving '%s' failed:\n\n%s"),
-                      gimp_file_get_utf8_name (file), error->message);
+                      gimp_file_get_utf8_name (file),
+                      error ? error->message : _("Unknown error"));
         g_clear_error (&error);
       }
       break;
diff --git a/app/file/file-save.c b/app/file/file-save.c
index 252d62a280..419ce92095 100644
--- a/app/file/file-save.c
+++ b/app/file/file-save.c
@@ -94,7 +94,11 @@ file_save (Gimp                *gimp,
   drawable = gimp_image_get_active_drawable (image);
 
   if (! drawable)
-    goto out;
+    {
+      g_set_error_literal (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
+                           _("There is no active layer to save"));
+      goto out;
+    }
 
   /* FIXME enable these tests for remote files again, needs testing */
   if (g_file_is_native (file) &&
@@ -108,7 +112,13 @@ file_save (Gimp                *gimp,
                                 G_FILE_QUERY_INFO_NONE,
                                 NULL, error);
       if (! info)
-        goto out;
+        {
+          /* extra paranoia */
+          if (error && ! *error)
+            g_set_error_literal (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
+                                 _("Failed to get file information"));
+          goto out;
+        }
 
       if (g_file_info_get_file_type (info) != G_FILE_TYPE_REGULAR)
         {


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