[librsvg: 1/8] rsvg_handle_get_dimensions_sub() - Don't panic if we get passed a nonexistent fragment identifier
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 1/8] rsvg_handle_get_dimensions_sub() - Don't panic if we get passed a nonexistent fragment identifier
- Date: Tue, 25 Sep 2018 23:50:25 +0000 (UTC)
commit 5a7b60ed4c75b33b314b37659c5c69049876d70d
Author: Federico Mena Quintero <federico gnome org>
Date: Tue Sep 25 16:35:11 2018 -0500
rsvg_handle_get_dimensions_sub() - Don't panic if we get passed a nonexistent fragment identifier
librsvg/rsvg-handle.c | 2 +-
tests/api.c | 4 ++++
2 files changed, 5 insertions(+), 1 deletion(-)
---
diff --git a/librsvg/rsvg-handle.c b/librsvg/rsvg-handle.c
index 912197b9..67c25bae 100644
--- a/librsvg/rsvg-handle.c
+++ b/librsvg/rsvg-handle.c
@@ -1227,7 +1227,7 @@ rsvg_handle_get_dimensions_sub (RsvgHandle * handle, RsvgDimensionData * dimensi
if (id && *id) {
node = rsvg_defs_lookup (handle->priv->defs, id);
- if (rsvg_tree_is_root (handle->priv->tree, node))
+ if (node && rsvg_tree_is_root (handle->priv->tree, node))
id = NULL;
} else {
node = root;
diff --git a/tests/api.c b/tests/api.c
index 73412041..130259eb 100644
--- a/tests/api.c
+++ b/tests/api.c
@@ -55,6 +55,7 @@ get_test_filename (const char *basename) {
#define EXAMPLE_ONE_ID "#one"
#define EXAMPLE_TWO_ID "#two"
+#define EXAMPLE_NONEXISTENT_ID "#nonexistent"
#define EXAMPLE_ONE_X 0
#define EXAMPLE_ONE_Y 0
@@ -462,6 +463,9 @@ dimensions_and_position (void)
g_assert_cmpint (pos.x, ==, EXAMPLE_TWO_X);
g_assert_cmpint (pos.y, ==, EXAMPLE_TWO_Y);
+ g_assert (!rsvg_handle_get_position_sub (handle, &pos, EXAMPLE_NONEXISTENT_ID));
+ g_assert (!rsvg_handle_get_dimensions_sub (handle, &dim, EXAMPLE_NONEXISTENT_ID));
+
g_object_unref (handle);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]