[glib] various GLib tests: plug memory leaks



commit 29f2ced8eb32d9001da8082c4530f017decb8267
Author: Simon McVittie <simon mcvittie collabora co uk>
Date:   Tue Dec 13 19:01:42 2011 +0000

    various GLib tests: plug memory leaks
    
    These don't really matter, since it's test code, but they do obscure
    real leaks in the library.
    
    Signed-off-by: Simon McVittie <simon mcvittie collabora co uk>
    Bug: https://bugzilla.gnome.org/show_bug.cgi?id=666115
    Acked-by: Matthias Clasen <mclasen redhat com>

 glib/tests/bookmarkfile.c   |    6 ++----
 glib/tests/cache.c          |    2 ++
 glib/tests/convert.c        |    4 ++++
 glib/tests/fileutils.c      |    4 ++++
 glib/tests/gvariant.c       |    1 +
 glib/tests/gwakeuptest.c    |    2 +-
 glib/tests/include.c        |    1 +
 glib/tests/keyfile.c        |    1 +
 glib/tests/mainloop.c       |    3 +++
 glib/tests/markup-parse.c   |   33 ++++++++++++++++++++++++++-------
 glib/tests/mem-overflow.c   |   23 +++++++++++++++++++----
 glib/tests/node.c           |    2 ++
 glib/tests/option-argv0.c   |    2 ++
 glib/tests/option-context.c |    3 +++
 glib/tests/protocol.c       |    6 ++++++
 glib/tests/queue.c          |   12 ++++++++++--
 glib/tests/sequence.c       |    7 +++++++
 glib/tests/strfuncs.c       |    5 ++++-
 glib/tests/string.c         |    4 ++++
 glib/tests/timeout.c        |    2 ++
 glib/tests/tree.c           |    1 +
 glib/tests/unix.c           |    3 +++
 glib/tests/uri.c            |   15 ++++++++++++++-
 gobject/tests/boxed.c       |    2 ++
 gobject/tests/param.c       |    1 +
 tests/testglib.c            |   12 ++++++++++++
 26 files changed, 137 insertions(+), 20 deletions(-)
---
diff --git a/glib/tests/bookmarkfile.c b/glib/tests/bookmarkfile.c
index 5e1eac7..9cd758b 100644
--- a/glib/tests/bookmarkfile.c
+++ b/glib/tests/bookmarkfile.c
@@ -29,11 +29,9 @@ test_load (GBookmarkFile *bookmark,
   
   res = g_bookmark_file_load_from_file (bookmark, filename, &error);
   if (error && g_test_verbose ())
-    {
-      g_print ("Load error: %s\n", error->message);
-      g_error_free (error);
-    }
+    g_print ("Load error: %s\n", error->message);
 
+  g_clear_error (&error);
   return res;
 }
 
diff --git a/glib/tests/cache.c b/glib/tests/cache.c
index 31ea9fa..e80c5af 100644
--- a/glib/tests/cache.c
+++ b/glib/tests/cache.c
@@ -150,7 +150,9 @@ test_cache_basic (void)
   g_assert_cmpint (value_create_count, ==, 2);
   g_assert_cmpint (value_destroy_count, ==, 1);
 
+  g_cache_remove (c, value);
   g_cache_destroy (c);
+  g_free (key);
 }
 
 int
diff --git a/glib/tests/convert.c b/glib/tests/convert.c
index 680f707..603142f 100644
--- a/glib/tests/convert.c
+++ b/glib/tests/convert.c
@@ -193,6 +193,7 @@ check_utf8_to_ucs4 (const char     *utf8,
       g_assert (result);
       for (i = 0; i <= items_written; i++)
 	g_assert (result[i] == ucs4[i]);
+      g_error_free (error3);
     }
   else if (error_pos)
     {
@@ -333,6 +334,7 @@ check_utf8_to_utf16 (const char      *utf8,
       g_assert (result);
       for (i = 0; i <= items_written; i++)
 	g_assert (result[i] == utf16[i]);
+      g_error_free (error3);
     }
   else if (error_pos)
     {
@@ -407,6 +409,7 @@ check_utf16_to_utf8 (const gunichar2 *utf16,
       g_assert (items_written == utf8_len);
       g_assert (result);
       g_assert (strcmp (result, utf8) == 0);
+      g_error_free (error3);
     }
   else if (error_pos)
     {
@@ -549,6 +552,7 @@ check_utf16_to_ucs4 (const gunichar2 *utf16,
       g_assert (result);
       for (i = 0; i <= items_written; i++)
 	g_assert (result[i] == ucs4[i]);
+      g_error_free (error3);
     }
   else if (error_pos)
     {
diff --git a/glib/tests/fileutils.c b/glib/tests/fileutils.c
index 544ec60..32f46a0 100644
--- a/glib/tests/fileutils.c
+++ b/glib/tests/fileutils.c
@@ -461,6 +461,10 @@ test_mkdir_with_parents_1 (const gchar *base)
   g_remove (p2);
   g_remove (p1);
   g_remove (p0);
+
+  g_free (p2);
+  g_free (p1);
+  g_free (p0);
 }
 
 static void
diff --git a/glib/tests/gvariant.c b/glib/tests/gvariant.c
index 29ca17b..18fe2fe 100644
--- a/glib/tests/gvariant.c
+++ b/glib/tests/gvariant.c
@@ -3729,6 +3729,7 @@ test_parses (void)
         printed = g_variant_print (value, FALSE);
         g_assert_cmpstr (tests[i], ==, printed);
         g_free (printed);
+        g_variant_unref (value);
       }
   }
 
diff --git a/glib/tests/gwakeuptest.c b/glib/tests/gwakeuptest.c
index c15dcdc..263327c 100644
--- a/glib/tests/gwakeuptest.c
+++ b/glib/tests/gwakeuptest.c
@@ -124,7 +124,7 @@ context_pop_token (struct context *ctx)
 
   g_mutex_lock (&ctx->lock);
   token = ctx->pending_tokens->data;
-  ctx->pending_tokens = g_slist_remove_link (ctx->pending_tokens,
+  ctx->pending_tokens = g_slist_delete_link (ctx->pending_tokens,
                                              ctx->pending_tokens);
   g_mutex_unlock (&ctx->lock);
 
diff --git a/glib/tests/include.c b/glib/tests/include.c
index acd7631..754450c 100644
--- a/glib/tests/include.c
+++ b/glib/tests/include.c
@@ -12,6 +12,7 @@ main (int argc, char *argv[])
   GRWLock lock;
 
   g_rw_lock_init (&lock);
+  g_rw_lock_clear (&lock);
 
   return 0;
 }
diff --git a/glib/tests/keyfile.c b/glib/tests/keyfile.c
index 93dbbc2..6d2f001 100644
--- a/glib/tests/keyfile.c
+++ b/glib/tests/keyfile.c
@@ -1396,6 +1396,7 @@ test_page_boundary (void)
       g_assert_cmpint (val, ==, VALUE);
     }
 
+  g_key_file_free (file);
 }
 
 static void
diff --git a/glib/tests/mainloop.c b/glib/tests/mainloop.c
index 067d9fc..980f7f5 100644
--- a/glib/tests/mainloop.c
+++ b/glib/tests/mainloop.c
@@ -64,6 +64,7 @@ test_maincontext_basic (void)
   g_source_set_priority (source, G_PRIORITY_HIGH);
   g_assert (g_source_get_priority (source) == G_PRIORITY_HIGH);
 
+  g_source_destroy (source);
   g_main_context_unref (ctx);
 
   ctx = g_main_context_default ();
@@ -95,6 +96,8 @@ test_mainloop_basic (void)
   g_main_loop_unref (loop);
 
   g_assert (g_main_depth () == 0);
+
+  g_main_loop_unref (loop);
 }
 
 static gint a;
diff --git a/glib/tests/markup-parse.c b/glib/tests/markup-parse.c
index 00191d7..7c1a044 100644
--- a/glib/tests/markup-parse.c
+++ b/glib/tests/markup-parse.c
@@ -176,12 +176,14 @@ test_file (const gchar *filename)
   if (!g_markup_parse_context_parse (context, contents, length, NULL))
     {
       g_markup_parse_context_free (context);
+      g_free (contents);
       return 1;
     }
 
   if (!g_markup_parse_context_end_parse (context, NULL))
     {
       g_markup_parse_context_free (context);
+      g_free (contents);
       return 1;
     }
 
@@ -189,23 +191,40 @@ test_file (const gchar *filename)
 
   /* A byte at a time */
   if (test_in_chunks (contents, length, 1) != 0)
-    return 1;
+    {
+      g_free (contents);
+      return 1;
+    }
 
   /* 2 bytes */
   if (test_in_chunks (contents, length, 2) != 0)
-    return 1;
+    {
+      g_free (contents);
+      return 1;
+    }
 
   /*5 bytes */
   if (test_in_chunks (contents, length, 5) != 0)
-    return 1;
-  
+    {
+      g_free (contents);
+      return 1;
+    }
+
   /* 12 bytes */
   if (test_in_chunks (contents, length, 12) != 0)
-    return 1;
-  
+    {
+      g_free (contents);
+      return 1;
+    }
+
   /* 1024 bytes */
   if (test_in_chunks (contents, length, 1024) != 0)
-    return 1;
+    {
+      g_free (contents);
+      return 1;
+    }
+
+  g_free (contents);
 
   return 0;
 }
diff --git a/glib/tests/mem-overflow.c b/glib/tests/mem-overflow.c
index 8649b24..0d483fb 100644
--- a/glib/tests/mem-overflow.c
+++ b/glib/tests/mem-overflow.c
@@ -34,6 +34,7 @@ mem_overflow (void)
   gpointer p, q;
   typedef char X[10];
 
+  /* "FAIL" here apparently means "fail to overflow"... */
 #define CHECK_PASS(P)	p = (P); g_assert (p == NULL);
 #define CHECK_FAIL(P)	p = (P); g_assert (p != NULL);
 
@@ -41,24 +42,28 @@ mem_overflow (void)
   CHECK_PASS (g_try_malloc_n (a, b));
   CHECK_PASS (g_try_malloc_n (b, a));
   CHECK_FAIL (g_try_malloc_n (b, b));
+  g_free (p);
 
   CHECK_PASS (g_try_malloc0_n (a, a));
   CHECK_PASS (g_try_malloc0_n (a, b));
   CHECK_PASS (g_try_malloc0_n (b, a));
   CHECK_FAIL (g_try_malloc0_n (b, b));
+  g_free (p);
 
   q = g_malloc (1);
   CHECK_PASS (g_try_realloc_n (q, a, a));
   CHECK_PASS (g_try_realloc_n (q, a, b));
   CHECK_PASS (g_try_realloc_n (q, b, a));
   CHECK_FAIL (g_try_realloc_n (q, b, b));
-  free (p);
+  g_free (p);
 
   CHECK_PASS (g_try_new (X, a));
   CHECK_FAIL (g_try_new (X, b));
+  g_free (p);
 
   CHECK_PASS (g_try_new0 (X, a));
   CHECK_FAIL (g_try_new0 (X, b));
+  g_free (p);
 
   q = g_try_malloc (1);
   CHECK_PASS (g_try_renew (X, q, a));
@@ -69,7 +74,17 @@ mem_overflow (void)
 #undef CHECK_PASS
 
 #define CHECK_FAIL(P)	if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR)) { p = (P); exit (0); } g_test_trap_assert_failed();
-#define CHECK_PASS(P)	if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR)) { p = (P); exit (0); } g_test_trap_assert_passed();
+
+#define CHECK_PASS(P)	do { \
+      if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR)) \
+        { \
+          p = (P); \
+          g_free (p); \
+          exit (0); \
+        } \
+      \
+      g_test_trap_assert_passed(); \
+    } while (0)
 
   CHECK_FAIL (g_malloc_n (a, a));
   CHECK_FAIL (g_malloc_n (a, b));
@@ -86,7 +101,7 @@ mem_overflow (void)
   CHECK_FAIL (g_realloc_n (q, a, b));
   CHECK_FAIL (g_realloc_n (q, b, a));
   CHECK_PASS (g_realloc_n (q, b, b));
-  free (q);
+  g_free (q);
 
   CHECK_FAIL (g_new (X, a));
   CHECK_PASS (g_new (X, b));
@@ -97,7 +112,7 @@ mem_overflow (void)
   q = g_malloc (1);
   CHECK_FAIL (g_renew (X, q, a));
   CHECK_PASS (g_renew (X, q, b));
-  free (q);
+  g_free (q);
 }
 
 typedef struct
diff --git a/glib/tests/node.c b/glib/tests/node.c
index 74f296f..27b5073 100644
--- a/glib/tests/node.c
+++ b/glib/tests/node.c
@@ -229,6 +229,8 @@ construct_test (void)
 
   for (i = 0; i < g_node_n_children (node_G); i++)
     g_assert_cmpint (g_node_child_position (node_G, g_node_nth_child (node_G, i)), ==, i);
+
+  g_node_destroy (root);
 }
 
 static void
diff --git a/glib/tests/option-argv0.c b/glib/tests/option-argv0.c
index 31fd83b..10fee28 100644
--- a/glib/tests/option-argv0.c
+++ b/glib/tests/option-argv0.c
@@ -45,6 +45,8 @@ test_platform_argv0 (void)
   g_assert (retval == TRUE);
   g_assert (strcmp (g_get_prgname(), "option-argv0") == 0
 	    || strcmp (g_get_prgname (), "lt-option-argv0") == 0);
+
+  g_option_context_free (context);
 }
 #endif
 
diff --git a/glib/tests/option-context.c b/glib/tests/option-context.c
index a42faeb..7cccddc 100644
--- a/glib/tests/option-context.c
+++ b/glib/tests/option-context.c
@@ -95,6 +95,7 @@ group_captions (void)
               g_setenv ("LANG", "C", TRUE);
 
               g_option_context_parse (options, &argc, &argv, &error);
+              g_option_context_free (options);
               exit(0);
             }
           else
@@ -161,6 +162,8 @@ group_captions (void)
                 g_test_trap_assert_stdout_unmatched ("*--help-test*");
             }
         }
+
+      g_option_context_free (options);
     }
 }
 
diff --git a/glib/tests/protocol.c b/glib/tests/protocol.c
index 4393f27..c40d2c0 100644
--- a/glib/tests/protocol.c
+++ b/glib/tests/protocol.c
@@ -218,6 +218,9 @@ test_message (void)
 
   g_assert_cmpint (passed, ==, 3);
   g_assert_cmpint (messages, ==, 3);
+
+  g_free (argv[1]);
+  g_main_loop_unref (loop);
 }
 
 static void
@@ -317,6 +320,9 @@ test_error (void)
               g_error ("unexpected log message type: %s", g_test_log_type_name (msg->log_type));
             }
         }
+
+      g_free (argv[1]);
+      g_main_loop_unref (loop);
     }
 
   g_assert_cmpint (messages, ==, 3);
diff --git a/glib/tests/queue.c b/glib/tests/queue.c
index 1c33d72..3aeea56 100644
--- a/glib/tests/queue.c
+++ b/glib/tests/queue.c
@@ -809,13 +809,19 @@ test_basic (void)
   g_assert (g_queue_pop_tail (q) == GINT_TO_POINTER (5));
   check_integrity (q);
   g_assert_cmpint (g_list_length (q->head), ==, 3);
-  g_assert (g_queue_pop_head_link (q)->data == GINT_TO_POINTER (2));
+
+  node = g_queue_pop_head_link (q);
+  g_assert (node->data == GINT_TO_POINTER (2));
+  g_list_free_1 (node);
+
   check_integrity (q);
   g_assert_cmpint (g_list_length (q->head), ==, 2);
   g_assert (g_queue_pop_tail (q) == GINT_TO_POINTER (4));
   check_integrity (q);
   g_assert_cmpint (g_list_length (q->head), ==, 1);
-  g_assert (g_queue_pop_head_link (q)->data == GINT_TO_POINTER (3));
+  node = g_queue_pop_head_link (q);
+  g_assert (node->data == GINT_TO_POINTER (3));
+  g_list_free_1 (node);
   check_integrity (q);
   g_assert_cmpint (g_list_length (q->head), ==, 0);
   g_assert (g_queue_pop_tail (q) == NULL);
@@ -853,6 +859,7 @@ test_basic (void)
   node = q->tail;
   g_assert (node == g_queue_pop_tail_link (q));
   check_integrity (q);
+  g_list_free_1 (node);
   g_assert_cmpint (g_list_length (q->head), ==, 3);
   data = q->head->data;
   g_assert (data == g_queue_pop_head (q));
@@ -957,6 +964,7 @@ test_off_by_one (void)
   g_assert (node == NULL);
   node = g_queue_pop_nth_link (q, g_queue_get_length (q) - 1);
   g_assert (node != NULL && node->data == GINT_TO_POINTER (1234));
+  g_list_free_1 (node);
 
   g_queue_free (q);
 }
diff --git a/glib/tests/sequence.c b/glib/tests/sequence.c
index b961548..8b1d64b 100644
--- a/glib/tests/sequence.c
+++ b/glib/tests/sequence.c
@@ -1180,6 +1180,13 @@ run_random_tests (gconstpointer d)
 
       check_integrity (seq);
     }
+
+  for (k = 0; k < N_SEQUENCES; ++k)
+    {
+      g_queue_free (sequences[k].queue);
+      g_sequence_free (sequences[k].sequence);
+      sequences[k].n_items = 0;
+    }
 }
 
 /* Random seeds known to have failed at one point
diff --git a/glib/tests/strfuncs.c b/glib/tests/strfuncs.c
index 0dffe87..d5e4f4c 100644
--- a/glib/tests/strfuncs.c
+++ b/glib/tests/strfuncs.c
@@ -841,6 +841,7 @@ test_strsplit_set (void)
 static void
 test_strv_length (void)
 {
+  gchar **strv;
   guint l;
 
   if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
@@ -849,8 +850,10 @@ test_strv_length (void)
     }
   g_test_trap_assert_failed ();
 
-  l = g_strv_length (g_strsplit ("1,2,3,4", ",", -1));
+  strv = g_strsplit ("1,2,3,4", ",", -1);
+  l = g_strv_length (strv);
   g_assert_cmpuint (l, ==, 4);
+  g_strfreev (strv);
 }
 
 static char *locales[] = {"sv_SE", "en_US", "fa_IR", "C", "ru_RU"};
diff --git a/glib/tests/string.c b/glib/tests/string.c
index 3d5d26e..19cb831 100644
--- a/glib/tests/string.c
+++ b/glib/tests/string.c
@@ -454,6 +454,8 @@ test_string_up_down (void)
   g_string_assign (s, "Mixed Case String !?");
   g_string_up (s);
   g_assert_cmpstr (s->str, ==, "MIXED CASE STRING !?");
+
+  g_string_free (s, TRUE);
 }
 
 static void
@@ -466,6 +468,8 @@ test_string_set_size (void)
 
   g_assert_cmpstr (s->str, ==, "foo");
   g_assert_cmpint (s->len, ==, 30);
+
+  g_string_free (s, TRUE);
 }
 
 int
diff --git a/glib/tests/timeout.c b/glib/tests/timeout.c
index bae2b4f..88d5ffe 100644
--- a/glib/tests/timeout.c
+++ b/glib/tests/timeout.c
@@ -41,6 +41,7 @@ test_seconds (void)
   g_timeout_add_seconds (21475, function, NULL);
 
   g_main_loop_run (loop);
+  g_main_loop_unref (loop);
 }
 
 static gint64 last_time;
@@ -86,6 +87,7 @@ test_rounding (void)
   g_timeout_add_seconds (1, test_func, NULL);
 
   g_main_loop_run (loop);
+  g_main_loop_unref (loop);
 }
 
 int
diff --git a/glib/tests/tree.c b/glib/tests/tree.c
index fa74186..ee129eb 100644
--- a/glib/tests/tree.c
+++ b/glib/tests/tree.c
@@ -336,6 +336,7 @@ test_tree_traverse (void)
   g_assert_cmpstr (result, ==, "02146538A9CEDB7GIHKMLJOQPSUTRNFWYXacbZegfikjhdmonqsrpuwvzyxtlV");
 
   g_tree_unref (tree);
+  g_free (result);
 }
 
 int
diff --git a/glib/tests/unix.c b/glib/tests/unix.c
index eb81c7a..feb2bb4 100644
--- a/glib/tests/unix.c
+++ b/glib/tests/unix.c
@@ -60,6 +60,7 @@ test_error (void)
   g_assert_cmpint (errno, ==, EBADF);
   g_assert (!res);
   g_assert_error (error, G_UNIX_ERROR, 0);
+  g_clear_error (&error);
 }
 
 static gboolean sig_received = FALSE;
@@ -110,6 +111,7 @@ test_signal (int signum)
   g_timeout_add (500, exit_mainloop, mainloop);
   g_main_loop_run (mainloop);
   g_assert (!sig_received);
+  g_main_loop_unref (mainloop);
 
 }
 
@@ -138,6 +140,7 @@ test_sighup_add_remove (void)
   g_source_remove (id);
   kill (getpid (), SIGHUP);
   g_assert (!sig_received);
+  g_main_loop_unref (mainloop);
 
 }
 
diff --git a/glib/tests/uri.c b/glib/tests/uri.c
index 097b195..c4f6678 100644
--- a/glib/tests/uri.c
+++ b/glib/tests/uri.c
@@ -184,6 +184,7 @@ run_to_uri_tests (void)
         g_assert_error (error, G_CONVERT_ERROR, to_uri_tests[i].expected_error);
 
       g_free (res);
+      g_clear_error (&error);
     }
 }
 
@@ -218,6 +219,10 @@ run_from_uri_tests (void)
       else
         g_assert_error (error, G_CONVERT_ERROR, from_uri_tests[i].expected_error);
       g_assert_cmpstr (hostname, ==, from_uri_tests[i].expected_hostname);
+
+      g_free (res);
+      g_free (hostname);
+      g_clear_error (&error);
     }
 }
 
@@ -285,6 +290,9 @@ run_roundtrip_tests (void)
 
       g_assert (safe_strcmp_filename (to_uri_tests[i].filename, res) == 0);
       g_assert (safe_strcmp_hostname (to_uri_tests[i].hostname, hostname) == 0);
+      g_free (res);
+      g_free (uri);
+      g_free (hostname);
     }
 }
 
@@ -316,12 +324,17 @@ run_uri_list_tests (void)
 
   uris = g_uri_list_extract_uris ("# just hot air\r\n# more hot air");
   g_assert_cmpint (g_strv_length (uris), ==, 0);
+  g_strfreev (uris);
 }
 
 static void
 test_uri_unescape (void)
 {
-  g_assert_cmpstr (g_uri_unescape_string ("%2Babc %4F",  NULL), ==, "+abc O");
+  gchar *s;
+
+  s = g_uri_unescape_string ("%2Babc %4F",  NULL);
+  g_assert_cmpstr (s, ==, "+abc O");
+  g_free (s);
   g_assert_cmpstr (g_uri_unescape_string ("%2Babc %4F",  "+"), ==, NULL);
   g_assert_cmpstr (g_uri_unescape_string ("%00abc %4F",  "+/"), ==, NULL);
   g_assert_cmpstr (g_uri_unescape_string ("%0",  NULL), ==, NULL);
diff --git a/gobject/tests/boxed.c b/gobject/tests/boxed.c
index 7b1e7d4..bd2cbad 100644
--- a/gobject/tests/boxed.c
+++ b/gobject/tests/boxed.c
@@ -56,6 +56,8 @@ test_define_boxed (void)
   g_assert_cmpstr (b->bla, ==, "bla");
 
   g_boxed_free (MY_TYPE_BOXED, b);
+
+  g_free (a.bla);
 }
 
 static void
diff --git a/gobject/tests/param.c b/gobject/tests/param.c
index d482e7b..5ab1a7d 100644
--- a/gobject/tests/param.c
+++ b/gobject/tests/param.c
@@ -25,6 +25,7 @@ test_param_value (void)
   g_param_spec_unref (p2);
 
   g_value_unset (&value);
+  g_param_spec_unref (pp);
 }
 
 static gint destroy_count;
diff --git a/tests/testglib.c b/tests/testglib.c
index 2b7725e..d41d674 100644
--- a/tests/testglib.c
+++ b/tests/testglib.c
@@ -448,6 +448,8 @@ binary_tree_test (void)
       g_tree_foreach (tree, my_traverse, NULL);
       g_print ("\n");
     }
+
+  g_tree_unref (tree);
 }
 
 static gboolean
@@ -943,6 +945,7 @@ test_file_functions (void)
   remove (template);
 
   error = NULL;
+  name_used = NULL;
   strcpy (template, "zap" G_DIR_SEPARATOR_S "barXXXXXX");
   fd = g_file_open_tmp (template, &name_used, &error);
   if (g_test_verbose())
@@ -955,8 +958,10 @@ test_file_functions (void)
   if (fd != -1)
     close (fd);
   g_clear_error (&error);
+  g_free (name_used);
 
 #ifdef G_OS_WIN32
+  name_used = NULL;
   strcpy (template, "zap/barXXXXXX");
   fd = g_file_open_tmp (template, &name_used, &error);
   if (g_test_verbose())
@@ -968,9 +973,11 @@ test_file_functions (void)
     }
   close (fd);
   g_clear_error (&error);
+  g_free (name_used);
 #endif
 
   strcpy (template, "zapXXXXXX");
+  name_used = NULL;
   fd = g_file_open_tmp (template, &name_used, &error);
   if (fd == -1)
     g_error ("g_file_open_tmp didn't work for template '%s': %s\n", template, error->message);
@@ -979,13 +986,16 @@ test_file_functions (void)
   close (fd);
   g_clear_error (&error);
   remove (name_used);
+  g_free (name_used);
 
+  name_used = NULL;
   fd = g_file_open_tmp (NULL, &name_used, &error);
   if (fd == -1)
     g_error ("g_file_open_tmp didn't work for a NULL template: %s\n", error->message);
   close (fd);
   g_clear_error (&error);
   remove (name_used);
+  g_free (name_used);
 }
 
 static void
@@ -1553,6 +1563,8 @@ test_mem_chunks (void)
     }
   for (i = 0; i < 10000; i++)
     g_mem_chunk_free (mem_chunk, mem[i]);
+
+  g_mem_chunk_destroy (mem_chunk);
 }
 #endif
 



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