[glib] Don't leak variants in the null settings backend



commit 8728949e0db56159485e5d214e581e5f46911d0b
Author: Christian Persch <chpe gnome org>
Date:   Thu Jan 6 23:30:09 2011 +0100

    Don't leak variants in the null settings backend
    
    Even though the write fails, the variant still needs to be consumed.
    
    Bug #638872.

 gio/gnullsettingsbackend.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
---
diff --git a/gio/gnullsettingsbackend.c b/gio/gnullsettingsbackend.c
index 507aa8c..d994f08 100644
--- a/gio/gnullsettingsbackend.c
+++ b/gio/gnullsettingsbackend.c
@@ -56,6 +56,18 @@ g_null_settings_backend_write (GSettingsBackend *backend,
                                GVariant         *value,
                                gpointer          origin_tag)
 {
+  if (value)
+    g_variant_unref (g_variant_ref_sink (value));
+  return FALSE;
+}
+
+static gboolean
+g_null_settings_backend_write_one (gpointer key,
+                                   gpointer value,
+                                   gpointer data)
+{
+  if (value)
+    g_variant_unref (g_variant_ref_sink (value));
   return FALSE;
 }
 
@@ -64,6 +76,7 @@ g_null_settings_backend_write_tree (GSettingsBackend *backend,
                                     GTree            *tree,
                                     gpointer          origin_tag)
 {
+  g_tree_foreach (tree, g_null_settings_backend_write_one, backend);
   return FALSE;
 }
 



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