diff options
author | Emmanuele Bassi <ebassi@gnome.org> | 2023-03-20 18:49:40 +0000 |
---|---|---|
committer | Emmanuele Bassi <ebassi@gmail.com> | 2023-03-20 23:23:33 +0000 |
commit | 3af7bf9410ac1f2755b435704f41d9efab1e58eb (patch) | |
tree | 08d5b1e949e9270b1513a7704f18c378cb612665 | |
parent | 0eb4eb1fa30211b61acc1bee7029e0a4f90994ca (diff) | |
download | gobject-introspection-3af7bf9410ac1f2755b435704f41d9efab1e58eb.tar.gz |
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.
-rw-r--r-- | girepository/gdump.c | 5 |
1 files changed, 4 insertions, 1 deletions
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, " <property name=\"%s\" type=\"%s\" flags=\"%d\" default-value=\"%s\"/>\n", prop->name, |