[librsvg] (#338): Don't panic when an image element doesn't have width/height attributes
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg] (#338): Don't panic when an image element doesn't have width/height attributes
- Date: Wed, 19 Sep 2018 16:42:24 +0000 (UTC)
commit 5992ad66f96a78be5c06239e9f1c01df60f1e1ab
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 8e6a511c..b1c6bc01 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::*;
@@ -122,6 +123,10 @@ impl NodeTrait for NodeImage {
let w = self.w.get().normalize(values, ¶ms);
let h = self.h.get().normalize(values, ¶ms);
+ 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]