[librsvg] Don't create pixbufs with zero width or height



commit 3ce97eb485492657df8665a960543d4222579dbe
Author: Christian Persch <chpe gnome org>
Date:   Wed Nov 9 21:00:53 2011 +0100

    Don't create pixbufs with zero width or height
    
    This created lots and lots of critical warnings when rendering
    tests/svg1.1/svg/filters-displace-01-f.svg:
    
    GdkPixbuf-CRITICAL **: gdk_pixbuf_new: assertion `width > 0' failed
    g_logv() [gmessages.c:779]
    g_log() [gmessages.c:826]
    g_return_if_fail_warning() [gmessages.c:838]
    gdk_pixbuf_new() [gdk-pixbuf.c:338]
    rsvg_filter_primitive_image_render_ext() [rsvg-filter.c:3376]

 rsvg-filter.c |   15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)
---
diff --git a/rsvg-filter.c b/rsvg-filter.c
index 75c15cf..eb218f2 100644
--- a/rsvg-filter.c
+++ b/rsvg-filter.c
@@ -3354,6 +3354,7 @@ rsvg_filter_primitive_image_render_ext (RsvgFilterPrimitive * self, RsvgFilterCo
     unsigned char *pixels;
     int channelmap[4];
     int length;
+    int width, height;
 
     upself = (RsvgFilterPrimitiveImage *) self;
 
@@ -3362,28 +3363,30 @@ rsvg_filter_primitive_image_render_ext (RsvgFilterPrimitive * self, RsvgFilterCo
 
     boundarys = rsvg_filter_primitive_get_bounds (self, ctx);
 
+    width = boundarys.x1 - boundarys.x0;
+    height = boundarys.y1 - boundarys.y0;
+    if (width == 0 || height == 0)
+        return NULL;
+
     img = rsvg_pixbuf_new_from_href (upself->href->str,
                                      rsvg_handle_get_base_uri (upself->ctx), NULL);
 
     if (!img)
         return NULL;
 
-
-    intermediate = gdk_pixbuf_new (GDK_COLORSPACE_RGB, 1, 8, boundarys.x1 - boundarys.x0,
-                                   boundarys.y1 - boundarys.y0);
+    intermediate = gdk_pixbuf_new (GDK_COLORSPACE_RGB, 1, 8, width, height);
 
 
     rsvg_art_affine_image (img, intermediate,
                            &ctx->paffine,
-                           (boundarys.x1 - boundarys.x0) / ctx->paffine.xx,
-                           (boundarys.y1 - boundarys.y0) / ctx->paffine.yy);
+                           (gdouble) width / ctx->paffine.xx,
+                           (gdouble) height / ctx->paffine.yy);
 
     if (!intermediate) {
         g_object_unref (img);
         return NULL;
     }
 
-
     g_object_unref (img);
 
     length = gdk_pixbuf_get_height (intermediate) * gdk_pixbuf_get_rowstride (intermediate);



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