From 3af7bf9410ac1f2755b435704f41d9efab1e58eb Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Mon, 20 Mar 2023 18:49:40 +0000 Subject: Protect ourselves against properties with no default value If the GParamSpec does not have a default value, we should not try to turn it into a string. --- girepository/gdump.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/girepository/gdump.c b/girepository/gdump.c index e68c4d14..a4ff42aa 100644 --- a/girepository/gdump.c +++ b/girepository/gdump.c @@ -125,6 +125,9 @@ invoke_error_quark (GModule *self, const char *symbol, GError **error) static char * value_to_string (const GValue *value) { + if (value == NULL) + return NULL; + if (G_VALUE_HOLDS_STRING (value)) { const char *s = g_value_get_string (value); @@ -186,7 +189,7 @@ dump_properties (GType type, GOutputStream *out) const GValue *v = g_param_spec_get_default_value (prop); char *default_value = value_to_string (v); - if (default_value != NULL) + if (v != NULL && default_value != NULL) { escaped_printf (out, " \n", prop->name, -- cgit v1.2.1