[librsvg] Only permit threadsafe pixbuf loaders



commit 9333f2da7ea92d475a45861fcf47dc385a783171
Author: Christian Persch <chpe gnome org>
Date:   Mon Nov 7 16:20:51 2011 +0100

    Only permit threadsafe pixbuf loaders
    
    When loading an embedded image using gdk-pixbuf, only use threadsafe
    pixbuf loaders. This prevents a deadlock with e.g. embedded TIFF images.
    This will cause the SVG to render without the embedded image; it will
    NOT cause the loading of the SVG to fail.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=473862
    https://bugzilla.gnome.org/show_bug.cgi?id=590788

 rsvg-image.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
---
diff --git a/rsvg-image.c b/rsvg-image.c
index 02882bd..9d7dc49 100644
--- a/rsvg-image.c
+++ b/rsvg-image.c
@@ -29,6 +29,7 @@
 
 #include "config.h"
 
+#define GDK_PIXBUF_ENABLE_BACKEND
 #include "rsvg-image.h"
 #include <string.h>
 #include <math.h>
@@ -188,9 +189,21 @@ rsvg_pixbuf_new_from_href (const char *href, const char *base_uri, GError ** err
     if (arr) {
         GdkPixbufLoader *loader;
         GdkPixbuf *pixbuf = NULL;
+        GdkPixbufFormat *format;
         int res;
 
         loader = gdk_pixbuf_loader_new ();
+        format = gdk_pixbuf_loader_get_format (loader);
+        if (format == NULL ||
+            (format->flags & GDK_PIXBUF_FORMAT_THREADSAFE) == 0) {
+            g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
+                         "Loader for format '%s' is not threadsafe; deadlock prevented.",
+                         format && format->name ? format->name : "(unknown)");
+            g_byte_array_free (arr, TRUE);
+            gdk_pixbuf_loader_close (loader, NULL /* ignore errors */);
+            g_object_unref (loader);
+            return NULL;
+        }
 
         res = gdk_pixbuf_loader_write (loader, arr->data, arr->len, error);
         g_byte_array_free (arr, TRUE);



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