[librsvg/librsvg-2.44] (#340): Don't panic when a marker has a zero-sized viewBox attribute



commit 9e730dd29d34bac6c908699d32a445c9680c9542
Author: Federico Mena Quintero <federico gnome org>
Date:   Tue Sep 18 17:46:39 2018 -0500

    (#340): Don't panic when a marker has a zero-sized viewBox attribute
    
    https://gitlab.gnome.org/GNOME/librsvg/issues/340

 rsvg_internals/src/marker.rs                                    | 7 ++++++-
 tests/fixtures/render-crash/340-marker-with-zero-sized-vbox.svg | 4 ++++
 2 files changed, 10 insertions(+), 1 deletion(-)
---
diff --git a/rsvg_internals/src/marker.rs b/rsvg_internals/src/marker.rs
index 7c22ac6b..f94c0d8c 100644
--- a/rsvg_internals/src/marker.rs
+++ b/rsvg_internals/src/marker.rs
@@ -140,7 +140,6 @@ impl NodeMarker {
         }
 
         let cr = draw_ctx.get_cairo_context();
-        cr.save();
 
         let mut affine = cr.get_matrix();
 
@@ -167,6 +166,10 @@ impl NodeMarker {
                 marker_height,
             );
 
+            if vbox.0.width.approx_eq_cairo(&0.0) || vbox.0.height.approx_eq_cairo(&0.0) {
+                return Ok(());
+            }
+
             affine.scale(w / vbox.0.width, h / vbox.0.height);
 
             draw_ctx.push_view_box(vbox.0.width, vbox.0.height);
@@ -179,6 +182,8 @@ impl NodeMarker {
             -self.ref_y.get().normalize(&values, draw_ctx),
         );
 
+        cr.save();
+
         cr.set_matrix(affine);
 
         if !values.is_overflow() {
diff --git a/tests/fixtures/render-crash/340-marker-with-zero-sized-vbox.svg 
b/tests/fixtures/render-crash/340-marker-with-zero-sized-vbox.svg
new file mode 100644
index 00000000..05c00ab8
--- /dev/null
+++ b/tests/fixtures/render-crash/340-marker-with-zero-sized-vbox.svg
@@ -0,0 +1,4 @@
+<svg>
+  <marker viewBox="0 0 0 0" id="m"/>
+  <path marker-start="url(#m)" d="M0 0 0 0"/>
+</svg>


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