[librsvg] (#467): Don't panic when there's an xi:include fallback with no parent element
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg] (#467): Don't panic when there's an xi:include fallback with no parent element
- Date: Tue, 4 Jun 2019 00:50:19 +0000 (UTC)
commit 3f89cc3907de1f87754b8a6892a25429b122c70a
Author: Federico Mena Quintero <federico gnome org>
Date: Mon Jun 3 19:47:19 2019 -0500
(#467): Don't panic when there's an xi:include fallback with no parent element
This came up from a fuzzed file. If we have a file that starts with
an xi:include, like
<xi:include><xi:fallback>foo</xi:fallback></xi:include>
Then the characters handler for "foo" would try to unwrap the current
element element so it can create a NodeChars node as a child of it,
but in this case there is no current element at all.
Fixes https://gitlab.gnome.org/GNOME/librsvg/issues/467
rsvg_internals/src/xml.rs | 8 +++++++-
tests/fixtures/crash/467-xinclude-without-parent-element.svg | 1 +
2 files changed, 8 insertions(+), 1 deletion(-)
---
diff --git a/rsvg_internals/src/xml.rs b/rsvg_internals/src/xml.rs
index ccd730a9..c7dce978 100644
--- a/rsvg_internals/src/xml.rs
+++ b/rsvg_internals/src/xml.rs
@@ -391,7 +391,13 @@ impl XmlState {
}
fn xinclude_fallback_characters(&mut self, ctx: &XIncludeContext, text: &str) {
- if ctx.need_fallback {
+ if ctx.need_fallback && self.current_node.is_some() {
+ // We test for is_some() because with a bad "SVG" file like this:
+ //
+ // <xi:include href="blah"><xi:fallback>foo</xi:fallback></xi:include>
+ //
+ // at the point we get "foo" here, there is no current_node because
+ // no nodes have been created before the xi:include.
self.element_creation_characters(text);
}
}
diff --git a/tests/fixtures/crash/467-xinclude-without-parent-element.svg
b/tests/fixtures/crash/467-xinclude-without-parent-element.svg
new file mode 100644
index 00000000..ea3c4a1f
--- /dev/null
+++ b/tests/fixtures/crash/467-xinclude-without-parent-element.svg
@@ -0,0 +1 @@
+<a:include href="1" b="c"><a:fallback>d<Wa>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]