mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-12 23:46:17 +01:00
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.
This commit is contained in:
parent
ffba6509da
commit
650090eefb
5
gdump.c
5
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,
|
||||
|
Loading…
Reference in New Issue
Block a user