[librsvg/librsvg-2.44] Fix filters crashing on non-invertible paffine



commit 9792cdbf90e7b41c65adc1726fd8d471154ac498
Author: Ivan Molodetskikh <yalterz gmail com>
Date:   Sat Sep 15 12:11:23 2018 +0300

    Fix filters crashing on non-invertible paffine

 rsvg_internals/src/filters/mod.rs                            | 12 +++++++++++-
 .../fixtures/render-crash/filters-non-invertible-paffine.svg |  7 +++++++
 2 files changed, 18 insertions(+), 1 deletion(-)
---
diff --git a/rsvg_internals/src/filters/mod.rs b/rsvg_internals/src/filters/mod.rs
index 3797b4c3..a685f317 100644
--- a/rsvg_internals/src/filters/mod.rs
+++ b/rsvg_internals/src/filters/mod.rs
@@ -2,7 +2,7 @@ use std::cell::{Cell, RefCell};
 use std::ops::Deref;
 use std::time::Instant;
 
-use cairo;
+use cairo::{self, MatrixTrait};
 use owning_ref::RcRef;
 
 use attributes::Attribute;
@@ -252,6 +252,16 @@ pub fn render(
     let mut filter_ctx =
         FilterContext::new(filter_node, node_being_filtered, source_surface, draw_ctx);
 
+    // If paffine is non-invertible, we won't draw anything. Also bbox combining in bounds
+    // computations will panic due to non-invertible martrix.
+    if filter_ctx.paffine().try_invert().is_err() {
+        return filter_ctx
+            .into_output()
+            .expect("could not create an empty surface to return from a filter")
+            .into_image_surface()
+            .expect("could not convert filter output into an ImageSurface");
+    }
+
     filter_node
         .children()
         // Skip nodes in error.
diff --git a/tests/fixtures/render-crash/filters-non-invertible-paffine.svg 
b/tests/fixtures/render-crash/filters-non-invertible-paffine.svg
new file mode 100644
index 00000000..8fdb09a1
--- /dev/null
+++ b/tests/fixtures/render-crash/filters-non-invertible-paffine.svg
@@ -0,0 +1,7 @@
+<svg>
+  <filter id="f" primitiveUnits="objectBoundingBox">
+    <feOffset/>
+  </filter>
+
+  <text filter="url(#f)"/>
+</svg>


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