g_settings_reset(): add precondition checks

Ensure that @key is non-%NULL on g_settings_reset().

It turns out that using g_settings_reset() with %NULL key (although
invalid as per the API documentation and not possible via bindings)
accidentally produces the same effect as the _reset_all() API that we
are about to add.

Add the standard precondition checks to prevent that from happening.

https://bugzilla.gnome.org/show_bug.cgi?id=744678
This commit is contained in:
Ryan Lortie 2015-02-19 12:21:48 -05:00 committed by Matthias Clasen
parent fdd0ed1972
commit ca03753853

View File

@ -2338,6 +2338,9 @@ g_settings_reset (GSettings *settings,
{ {
gchar *path; gchar *path;
g_return_if_fail (G_IS_SETTINGS (settings));
g_return_if_fail (key != NULL);
path = g_strconcat (settings->priv->path, key, NULL); path = g_strconcat (settings->priv->path, key, NULL);
g_settings_backend_reset (settings->priv->backend, path, NULL); g_settings_backend_reset (settings->priv->backend, path, NULL);
g_free (path); g_free (path);