[librsvg/librsvg-2.44] rsvg_handle_get_dimensions_sub() - Don't panic if we get passed a nonexistent fragment identifier



commit 5665114773975ef6f44c6fe9fa3a386c04d19100
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 25eca410..bfbf4f47 100644
--- a/librsvg/rsvg-handle.c
+++ b/librsvg/rsvg-handle.c
@@ -1224,7 +1224,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]