[librsvg/librsvg-2.40] bgo#777155 - Ignore patterns that have close-to-zero dimensions
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg/librsvg-2.40] bgo#777155 - Ignore patterns that have close-to-zero dimensions
- Date: Wed, 4 Oct 2017 15:34:29 +0000 (UTC)
commit 05fd03117bffbae36b28b5ea7934520b46751476
Author: Federico Mena Quintero <federico gnome org>
Date: Wed Jan 11 15:33:31 2017 -0600
bgo#777155 - Ignore patterns that have close-to-zero dimensions
A fuzzed file yielded a pattern that had (0, 0) for a pattern's width
and height. We try to invert a scaling matrix based on those
dimensions; this would fail for such a pattern. Now we ignore patterns
that have unspecified dimensions, or that are very close to zero.
https://bugzilla.gnome.org/show_bug.cgi?id=777155
rsvg-cairo-draw.c | 13 ++++--
.../render-crash/777155-zero-sized-pattern.svg | 50 ++++++++++++++++++++
2 files changed, 59 insertions(+), 4 deletions(-)
---
diff --git a/rsvg-cairo-draw.c b/rsvg-cairo-draw.c
index 71a981e..caa9104 100644
--- a/rsvg-cairo-draw.c
+++ b/rsvg-cairo-draw.c
@@ -189,6 +189,7 @@ _set_source_rsvg_pattern (RsvgDrawingCtx * ctx,
cairo_matrix_t affine, caffine, taffine;
double bbwscale, bbhscale, scwscale, schscale;
double patternw, patternh, patternx, patterny;
+ double scaled_width, scaled_height;
int pw, ph;
rsvg_pattern = &local_pattern;
@@ -206,10 +207,8 @@ _set_source_rsvg_pattern (RsvgDrawingCtx * ctx,
if (rsvg_pattern->obj_bbox)
_rsvg_pop_view_box (ctx);
-
/* Work out the size of the rectangle so it takes into account the object bounding box */
-
if (rsvg_pattern->obj_bbox) {
bbwscale = bbox.rect.width;
bbhscale = bbox.rect.height;
@@ -226,8 +225,14 @@ _set_source_rsvg_pattern (RsvgDrawingCtx * ctx,
pw = patternw * bbwscale * scwscale;
ph = patternh * bbhscale * schscale;
- scwscale = (double) pw / (double) (patternw * bbwscale);
- schscale = (double) ph / (double) (patternh * bbhscale);
+ scaled_width = patternw * bbwscale;
+ scaled_height = patternh * bbhscale;
+
+ if (fabs (scaled_width) < DBL_EPSILON || fabs (scaled_height) < DBL_EPSILON)
+ return;
+
+ scwscale = pw / scaled_width;
+ schscale = ph / scaled_height;
surface = cairo_surface_create_similar (cairo_get_target (cr_render),
CAIRO_CONTENT_COLOR_ALPHA, pw, ph);
diff --git a/tests/fixtures/render-crash/777155-zero-sized-pattern.svg
b/tests/fixtures/render-crash/777155-zero-sized-pattern.svg
new file mode 100644
index 0000000..1412da4
--- /dev/null
+++ b/tests/fixtures/render-crash/777155-zero-sized-pattern.svg
@@ -0,0 +1,50 @@
+<svg id="svgt" width="100%" height="100%" viewBox="0 0 480 3">
+ <!--======-->
+ <!--= =-->
+ <!--= =-->
+ <!--= =-->
+ <!--= =-->
+ <!--= =-->
+ <!--======-->
+ <d:SVGTestCase s:d="httt" s="$R$">
+<d:testDescription x="hts">
+ <p>
+ </p>
+ <p> </p>
+ </d:testDescription>
+<d:operatorScript xmlns="httl">
+ <p>Runed.</p>
+</d:operatorScript>
+<d:passCriteria s="html">
+ <p>
+ </p>
+ </d:passCriteria>
+ </d:SVGTestCase>
+ <title id="testle">$RC</title>
+ <defs>
+ <font-face font-family=""
+ e="UF">
+ <font-face-src>
+ <f xliref="../cii"/>
+ </font-face-src>
+ </font-face>
+ </defs>
+ <g id="teent" font-family="SVf" font-size="18">
+ <defs>
+ <patterl id="Pattern1" patternUnits="userSpaceOnUse" width="100" height="100" viewBox="0 0 10 10" />
+ <pattern id="Pattern2" xlink:href="#Pattern1" />
+<pattern id="Pattern3" xlink:href="#Pattern2">
+ <circle cx="5" cy="5" r="2" fill="green"/>
+ </pattern> </defs> <circle cx="50" cy="50" r="20" fill="red" />
+ <rect fill="url(#Pattern3)" width="100" height="100" />
+ </g>
+ <g font-family="Sif" font-size="32">
+<text id="re0" stroke="none" fill="black">ision: 1.3 $</text>
+ </g>
+ <rect id="te" x="1" y="1" width="478" height="358" fill="none" stroke="#000"/>
+ <!-- c-->
+ <g id="dra">
+ <rect x="1" y="1" width="478" height="20" fill="red" stroke="black" stroke-width="1"/>
+ <text font-family="SVG" font-weighR="bold" font-size="20" text-anchor="middle" y="18"
stroke-width="0.5" stroke="black" fill="white">DRAFT</text>
+ </g>
+</svg>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]