[glib] fix leaks in the GSettings test case



commit 519edcc2b3fd23fc29b38b581480adf39dd93451
Author: Ryan Lortie <desrt desrt ca>
Date:   Thu Jun 24 00:36:42 2010 -0400

    fix leaks in the GSettings test case

 gio/tests/gsettings.c |   27 +++++++++++++++++++++++----
 1 files changed, 23 insertions(+), 4 deletions(-)
---
diff --git a/gio/tests/gsettings.c b/gio/tests/gsettings.c
index 46223b6..22ed31a 100644
--- a/gio/tests/gsettings.c
+++ b/gio/tests/gsettings.c
@@ -27,6 +27,7 @@ test_basic (void)
 
   g_settings_get (settings, "greeting", "s", &str);
   g_assert_cmpstr (str, ==, "Hello, earthlings");
+  g_free (str);
 
   g_settings_set (settings, "greeting", "s", "goodbye world");
   g_settings_get (settings, "greeting", "s", &str);
@@ -1005,6 +1006,7 @@ test_custom_binding (void)
   g_object_set (obj, "bool", TRUE, NULL);
   s = g_settings_get_string (settings, "string");
   g_assert_cmpstr (s, ==, "true");
+  g_free (s);
 
   g_object_unref (obj);
   g_object_unref (settings);
@@ -1251,6 +1253,7 @@ static void
 test_enums (void)
 {
   GSettings *settings, *direct;
+  gchar *str;
 
   settings = g_settings_new ("org.gtk.test.enums");
   direct = g_settings_new ("org.gtk.test.enums.direct");
@@ -1273,13 +1276,28 @@ test_enums (void)
       g_test_trap_assert_stderr ("*g_settings_range_check*");
     }
 
-  g_assert_cmpstr (g_settings_get_string (settings, "test"), ==, "bar");
+  str = g_settings_get_string (settings, "test");
+  g_assert_cmpstr (str, ==, "bar");
+  g_free (str);
+
   g_settings_set_enum (settings, "test", TEST_ENUM_FOO);
-  g_assert_cmpstr (g_settings_get_string (settings, "test"), ==, "foo");
+
+  str = g_settings_get_string (settings, "test");
+  g_assert_cmpstr (str, ==, "foo");
+  g_free (str);
+
   g_assert_cmpint (g_settings_get_enum (settings, "test"), ==, TEST_ENUM_FOO);
+
   g_settings_set_string (direct, "test", "qux");
-  g_assert_cmpstr (g_settings_get_string (direct, "test"), ==, "qux");
-  g_assert_cmpstr (g_settings_get_string (settings, "test"), ==, "quux");
+
+  str = g_settings_get_string (direct, "test");
+  g_assert_cmpstr (str, ==, "qux");
+  g_free (str);
+
+  str = g_settings_get_string (settings, "test");
+  g_assert_cmpstr (str, ==, "quux");
+  g_free (str);
+
   g_assert_cmpint (g_settings_get_enum (settings, "test"), ==, TEST_ENUM_QUUX);
 }
 
@@ -1341,6 +1359,7 @@ main (int argc, char *argv[])
                                        &enums, NULL, &result, NULL));
   g_assert (result == 0);
   g_assert (g_file_set_contents ("org.gtk.test.enums.xml", enums, -1, NULL));
+  g_free (enums);
 
   g_remove ("gschemas.compiled");
   g_assert (g_spawn_command_line_sync ("../glib-compile-schemas --targetdir=. "



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