diff options
author | Emmanuele Bassi <ebassi@gnome.org> | 2023-03-20 21:42:11 +0000 |
---|---|---|
committer | Marge Bot <marge-bot@gnome.org> | 2023-03-21 13:47:51 +0000 |
commit | bc9cad512451d3f5d63c1892668d1c7aec370227 (patch) | |
tree | c66ad79b312a4cce6dbf493e4534652591c139b6 | |
parent | 4f47ba26be8ba7e2da09360ca67190a90589a065 (diff) | |
download | mutter-bc9cad512451d3f5d63c1892668d1c7aec370227.tar.gz |
clutter: Safely transform paths to strings and vice versa
GValues containing objects and strings can be set to NULL, which means
the transformation functions from ClutterPath to string and vice versa
must be NULL-safe.
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2625
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2929>
-rw-r--r-- | clutter/clutter/clutter-path.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/clutter/clutter/clutter-path.c b/clutter/clutter/clutter-path.c index 9c0155de8..6d0fc0110 100644 --- a/clutter/clutter/clutter-path.c +++ b/clutter/clutter/clutter-path.c @@ -211,19 +211,26 @@ static void clutter_value_transform_path_string (const GValue *src, GValue *dest) { - gchar *string = clutter_path_get_description (src->data[0].v_pointer); + if (src->data[0].v_pointer != NULL) + { + gchar *string = clutter_path_get_description (src->data[0].v_pointer); - g_value_take_string (dest, string); + g_value_take_string (dest, string); + } } static void clutter_value_transform_string_path (const GValue *src, GValue *dest) { - ClutterPath *new_path; + const char *str; - new_path = clutter_path_new_with_description (g_value_get_string (src)); - g_value_take_object (dest, new_path); + str = g_value_get_string (src); + if (str != NULL) + { + ClutterPath *new_path = clutter_path_new_with_description (str); + g_value_take_object (dest, new_path); + } } static void |