[glib] g_settings_reset(): add precondition checks



commit ca037538535c49a21f32a1cef35972892222e01e
Author: Ryan Lortie <desrt desrt ca>
Date:   Thu Feb 19 12:21:48 2015 -0500

    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

 gio/gsettings.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
---
diff --git a/gio/gsettings.c b/gio/gsettings.c
index 3841b54..3e2ae44 100644
--- a/gio/gsettings.c
+++ b/gio/gsettings.c
@@ -2338,6 +2338,9 @@ g_settings_reset (GSettings *settings,
 {
   gchar *path;
 
+  g_return_if_fail (G_IS_SETTINGS (settings));
+  g_return_if_fail (key != NULL);
+
   path = g_strconcat (settings->priv->path, key, NULL);
   g_settings_backend_reset (settings->priv->backend, path, NULL);
   g_free (path);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]