[librsvg] rsvg_decode_data_uri(): Restore ability to pass a null out_mime_type
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg] rsvg_decode_data_uri(): Restore ability to pass a null out_mime_type
- Date: Sun, 18 Nov 2018 23:16:34 +0000 (UTC)
commit aeb168ae1b7bbecb31cca5dca162bcb6d9938791
Author: Federico Mena Quintero <federico gnome org>
Date: Sun Nov 18 16:53:03 2018 -0600
rsvg_decode_data_uri(): Restore ability to pass a null out_mime_type
Merge request !153 was due to a bug when calling
rsvg_decode_data_uri() with out_mime_type=NULL. This was allowed in
the pre-rustification version of that function. This commit restores
that behavior, and adds a test for
<xi:include href="data:text/xml,<xml...">
since the tests were not hitting that code path, which contained the crash.
rsvg_internals/src/io.rs | 11 ++++++++---
tests/fixtures/crash/xinclude-text-xml.svg | 28 ++++++++++++++++++++++++++++
2 files changed, 36 insertions(+), 3 deletions(-)
---
diff --git a/rsvg_internals/src/io.rs b/rsvg_internals/src/io.rs
index d534ae2e..37963b58 100644
--- a/rsvg_internals/src/io.rs
+++ b/rsvg_internals/src/io.rs
@@ -32,14 +32,16 @@ pub fn rsvg_decode_data_uri(
error: *mut *mut glib_sys::GError,
) -> *mut libc::c_char {
unsafe {
- assert!(!out_mime_type.is_null());
assert!(!out_size.is_null());
let uri = utf8_cstr(uri);
match decode_data_uri(uri) {
Ok(binary_data) => {
- *out_mime_type = binary_data.content_type.to_glib_full();
+ if !out_mime_type.is_null() {
+ *out_mime_type = binary_data.content_type.to_glib_full();
+ }
+
*out_size = binary_data.data.len();
if !error.is_null() {
@@ -51,7 +53,10 @@ pub fn rsvg_decode_data_uri(
}
Err(_) => {
- *out_mime_type = ptr::null_mut();
+ if !out_mime_type.is_null() {
+ *out_mime_type = ptr::null_mut();
+ }
+
*out_size = 0;
set_gerror(error, 0, "could not decode data: URL");
diff --git a/tests/fixtures/crash/xinclude-text-xml.svg b/tests/fixtures/crash/xinclude-text-xml.svg
new file mode 100644
index 00000000..3222b6c1
--- /dev/null
+++ b/tests/fixtures/crash/xinclude-text-xml.svg
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg version="1.1"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xi="http://www.w3.org/2001/XInclude"
+ width="16"
+ height="16">
+ <style type="text/css">
+ rect,circle,path {
+ fill: rgb(0,255,0) !important;
+ }
+ .warning {
+ fill: rgb(0,255,0) !important;
+ }
+ .error {
+ fill: rgb(0,255,0) !important;
+ }
+ .success {
+ fill: rgb(255,0,0) !important;
+ }
+ </style>
+ <xi:include href="data:text/xml,<svg xmlns="http://www.w3.org/2000/svg" width="16"
height="16">
+ <g color="#bebebe" font-weight="400" fill="#474747">
+ <path d="M1.75 4C.798 4 0 4.798 0 5.75v4.5C0 11.202.798 12 1.75 12h.125l-.781 1.563L.375
15h9.25l-.719-1.437L8.125 12h.125c.952 0 1.75-.798 1.75-1.75v-4.5C10 4.798 9.202 4 8.25 4zM2 6h6v4H2z"
style="line-height:normal;-inkscape-font-specification:Sans;text-indent:0;text-align:start;text-decoration-line:none;text-transform:none;marker:none"
font-family="Sans" overflow="visible"/>
+ <path d="M7.75 1C6.798 1 6 1.798 6 2.75V3h8v4h-3v3.25c0 .66-.252 1.27-.656
1.75h5.28l-1.5-3h.126C15.202 9 16 8.202 16 7.25v-4.5C16 1.798 15.202 1 14.25 1z"
style="line-height:normal;text-indent:0;text-align:start;text-decoration-line:none;text-transform:none;marker:none"
font-family="Andale Mono" overflow="visible"/>
+ </g>
+</svg>
+"/>
+</svg>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]