[Xfce4-commits] <xfce4-screenshooter:master> Fix crash with NULL save path (bug #8443).

Jérôme Guelfucci noreply at xfce.org
Mon Feb 13 17:18:01 CET 2012


Updating branch refs/heads/master
         to 06c67fedab4dd03499485740209db7c5220a83e7 (commit)
       from 336f7822b273d9b843b318a4e8a2976824f54473 (commit)

commit 06c67fedab4dd03499485740209db7c5220a83e7
Author: Jérôme Guelfucci <jeromeg at xfce.org>
Date:   Mon Feb 13 17:14:16 2012 +0100

    Fix crash with NULL save path (bug #8443).
    
    The gdk_pixbuf_save documentation was not exactly clear on that, will
    file a bug.

 lib/screenshooter-dialogs.c |   18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/lib/screenshooter-dialogs.c b/lib/screenshooter-dialogs.c
index 8680118..104190a 100644
--- a/lib/screenshooter-dialogs.c
+++ b/lib/screenshooter-dialogs.c
@@ -203,9 +203,9 @@ static void cb_delay_spinner_changed (GtkWidget *spinner, ScreenshotData *sd)
 /* If @timestamp is true, generates a file name @title - date - hour - n.png,
  * where n is the lowest integer such as this file does not exist in the @uri
  * folder.
- * Else, generates a file name @title-n.png, where n is the lowest integer 
+ * Else, generates a file name @title-n.png, where n is the lowest integer
  * such as this file does not exist in the @uri folder.
- * 
+ *
  * @uri: uri of the folder for which the filename should be generated.
  * @title: the main title of the file name.
  * @timestamp: whether the date and the hour should be appended to the file name.
@@ -510,9 +510,13 @@ static gchar
 
   if (G_UNLIKELY (!gdk_pixbuf_save (screenshot, save_path, "png", &error, NULL)))
     {
-      screenshooter_error ("%s", error->message);
+      if (error)
+        {
+          /* See bug #8443, looks like error is not set when path is NULL */
+          screenshooter_error ("%s", error->message);
+          g_error_free (error);
+        }
 
-      g_error_free (error);
       g_free (save_path);
 
       return NULL;
@@ -606,6 +610,12 @@ static gchar
   GFile *save_file = g_file_new_for_uri (save_uri);
   gchar *result = NULL;
 
+  if (save_uri == NULL)
+    {
+      g_object_unref (save_file);
+      return NULL;
+    }
+
   /* If the URI is a local one, we save directly */
 
   if (!screenshooter_is_remote_uri (save_uri))


More information about the Xfce4-commits mailing list