[librsvg/librsvg-2.44] (#338): Don't panic when an image element doesn't have width/height attributes



commit b67c524f66ea416657eaff8ca31fd826bb7f3f34
Author: Federico Mena Quintero <federico gnome org>
Date:   Tue Sep 18 17:30:42 2018 -0500

    (#338): Don't panic when an image element doesn't have width/height attributes
    
    https://gitlab.gnome.org/GNOME/librsvg/issues/338

 rsvg_internals/src/image.rs                          | 5 +++++
 tests/fixtures/render-crash/338-zero-sized-image.svg | 3 +++
 2 files changed, 8 insertions(+)
---
diff --git a/rsvg_internals/src/image.rs b/rsvg_internals/src/image.rs
index d5952c0b..1c07f75e 100644
--- a/rsvg_internals/src/image.rs
+++ b/rsvg_internals/src/image.rs
@@ -13,6 +13,7 @@ use attributes::Attribute;
 use bbox::BoundingBox;
 use drawing_ctx::DrawingCtx;
 use error::RenderingError;
+use float_eq_cairo::ApproxEqCairo;
 use handle::RsvgHandle;
 use length::*;
 use node::*;
@@ -120,6 +121,10 @@ impl NodeTrait for NodeImage {
             let w = self.w.get().normalize(values, draw_ctx);
             let h = self.h.get().normalize(values, draw_ctx);
 
+            if w.approx_eq_cairo(&0.0) || h.approx_eq_cairo(&0.0) {
+                return Ok(());
+            }
+
             draw_ctx.with_discrete_layer(node, values, clipping, &mut |dc| {
                 let aspect = self.aspect.get();
 
diff --git a/tests/fixtures/render-crash/338-zero-sized-image.svg 
b/tests/fixtures/render-crash/338-zero-sized-image.svg
new file mode 100644
index 00000000..e0fa05d3
--- /dev/null
+++ b/tests/fixtures/render-crash/338-zero-sized-image.svg
@@ -0,0 +1,3 @@
+<svg>
+  <image xlink:href="data:;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AA0000lEQVQ0"/>
+</svg>


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