mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-27 06:26:15 +01:00
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
This commit is contained in:
parent
c07eccd9c2
commit
396d40af23
@ -1528,6 +1528,13 @@ g_settings_get (GSettings *settings,
|
|||||||
|
|
||||||
value = g_settings_get_value (settings, key);
|
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);
|
va_start (ap, format);
|
||||||
g_variant_get_va (value, format, NULL, &ap);
|
g_variant_get_va (value, format, NULL, &ap);
|
||||||
va_end (ap);
|
va_end (ap);
|
||||||
|
Loading…
Reference in New Issue
Block a user