[gdk-pixbuf] thumbnailer: Update skeleton to fix a possible crash



commit 57362ed4c1f37c05723e25e136327e262f32d35f
Author: Bastien Nocera <hadess hadess net>
Date:   Thu Jul 27 13:14:10 2017 +0100

    thumbnailer: Update skeleton to fix a possible crash
    
    If the loader returns a NULL pixbuf without returning an
    error, the skeleton would crash trying to print the error.
    Print that the thumbnailer is broken instead.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=778204

 thumbnailer/gnome-thumbnailer-skeleton.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/thumbnailer/gnome-thumbnailer-skeleton.c b/thumbnailer/gnome-thumbnailer-skeleton.c
index d686432..73da53e 100644
--- a/thumbnailer/gnome-thumbnailer-skeleton.c
+++ b/thumbnailer/gnome-thumbnailer-skeleton.c
@@ -37,6 +37,7 @@ static int output_size = 256;
 static gboolean g_fatal_warnings = FALSE;
 static char **filenames = NULL;
 
+#if !GDK_PIXBUF_CHECK_VERSION(2,36,5)
 /**
  * gnome_desktop_thumbnail_scale_down_pixbuf:
  * @pixbuf: a #GdkPixbuf
@@ -178,6 +179,7 @@ gnome_desktop_thumbnail_scale_down_pixbuf (GdkPixbuf *pixbuf,
        
        return dest_pixbuf;
 }
+#endif
 
 static char *
 get_target_uri (GFile *file)
@@ -291,9 +293,16 @@ int main (int argc, char **argv)
 
                        scale = (double)output_size / MAX (width, height);
 
+#if !GDK_PIXBUF_CHECK_VERSION(2,36,5)
                        scaled = gnome_desktop_thumbnail_scale_down_pixbuf (pixbuf,
                                                                            floor (width * scale + 0.5),
                                                                            floor (height * scale + 0.5));
+#else
+                       scaled = gdk_pixbuf_scale_simple (pixbuf,
+                                                         floor (width * scale + 0.5),
+                                                         floor (height * scale + 0.5),
+                                                         GDK_INTERP_HYPER);
+#endif
                        gdk_pixbuf_copy_options (pixbuf, scaled);
                        g_object_unref (pixbuf);
                        pixbuf = scaled;
@@ -316,8 +325,9 @@ int main (int argc, char **argv)
        g_free (input_filename);
 
        if (!pixbuf) {
-               g_warning ("Could not thumbnail '%s': %s", filenames[0], error->message);
-               g_error_free (error);
+               g_warning ("Could not thumbnail '%s': %s", filenames[0],
+                          error ? error->message : "Thumbnailer failed without returning an error");
+               g_clear_error (&error);
                g_strfreev (filenames);
                return 1;
        }


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