summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Uebernickel <lars@uebernic.de>2013-12-06 16:01:48 +0100
committerLars Uebernickel <lars@uebernic.de>2013-12-06 16:48:00 +0100
commit396d40af237db00e1014520cf6858cfed30bbc51 (patch)
treebfa4c5e3938807fab91e98eb7c19c0e894423e85
parentc07eccd9c212e1e1642ee8cd359f5066ee8e5295 (diff)
downloadglib-396d40af237db00e1014520cf6858cfed30bbc51.tar.gz
g_settings_get: check validity of format string
Allow only format strings that copy all values (i.e, don't contain '&'), as the returned pointers might become invalid in some rare cases. Since this is technically an API break, this patch only prints a critical when a faulty format string is detected, but still fetches the values. https://bugzilla.gnome.org/show_bug.cgi?id=719979
-rw-r--r--gio/gsettings.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/gio/gsettings.c b/gio/gsettings.c
index e0407deac..62a170801 100644
--- a/gio/gsettings.c
+++ b/gio/gsettings.c
@@ -1528,6 +1528,13 @@ g_settings_get (GSettings *settings,
value = g_settings_get_value (settings, key);
+ if (!g_variant_check_format_string (value, format, TRUE))
+ {
+ g_critical ("%s: invalid format string for key '%s' from schema '%s'. "
+ "This call will probably stop working with a future version of glib.",
+ G_STRFUNC, key, g_settings_schema_get_id (settings->priv->schema));
+ }
+
va_start (ap, format);
g_variant_get_va (value, format, NULL, &ap);
va_end (ap);