Commit 3ce97eb4 authored by Christian Persch's avatar Christian Persch

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]
parent f983fc12
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment