[gnome-desktop] thumbnailer: Bail if no pixbuf loader could be created



commit b2d6cc3542b8b2fa787253bb45c22b5a151ac164
Author: Philip Withnall <philip withnall collabora co uk>
Date:   Thu Oct 10 14:22:35 2013 +0100

    thumbnailer: Bail if no pixbuf loader could be created
    
    This prevents gdk_pixbuf_loader_close() from emitting a critical
    error due to being called with a NULL loader. The loader can be NULL
    if there was an error in the first read from the input stream.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=709819

 libgnome-desktop/gnome-desktop-thumbnail.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/libgnome-desktop/gnome-desktop-thumbnail.c b/libgnome-desktop/gnome-desktop-thumbnail.c
index 6c31a97..68294dd 100644
--- a/libgnome-desktop/gnome-desktop-thumbnail.c
+++ b/libgnome-desktop/gnome-desktop-thumbnail.c
@@ -440,14 +440,18 @@ _gdk_pixbuf_new_from_uri_at_scale (const char *uri,
        }
     }
 
-    if (gdk_pixbuf_loader_close (loader, &error) == FALSE) {
+    if (loader == NULL) {
+        /* This can happen if the above loop was exited due to the
+         * g_input_stream_read() call failing. */
+        result = FALSE;
+    } else if (gdk_pixbuf_loader_close (loader, &error) == FALSE) {
         g_warning ("Error creating thumbnail for %s: %s", uri, error->message);
         g_clear_error (&error);
         result = FALSE;
     }
 
     if (!result) {
-       g_object_unref (G_OBJECT (loader));
+        g_clear_object (&loader);
        g_input_stream_close (input_stream, NULL, NULL);
        g_object_unref (input_stream);
        g_object_unref (file);


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