From a4612a922bc984ff45e2096d2d286da1be5be481 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Fri, 26 Sep 2014 16:18:46 +0100 Subject: [PATCH] tests: Fix some minor leaks in the unit tests https://bugzilla.gnome.org/show_bug.cgi?id=737446 --- glib/tests/bookmarkfile.c | 1 + glib/tests/fileutils.c | 3 ++- glib/tests/option-context.c | 8 ++++++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/glib/tests/bookmarkfile.c b/glib/tests/bookmarkfile.c index 00605ed4c..7c2f8d7a4 100644 --- a/glib/tests/bookmarkfile.c +++ b/glib/tests/bookmarkfile.c @@ -31,6 +31,7 @@ test_load_from_data_dirs (void) g_assert (!res); g_assert_error (error, G_FILE_ERROR, G_FILE_ERROR_NOENT); g_assert_null (path); + g_error_free (error); g_bookmark_file_free (bookmark); } diff --git a/glib/tests/fileutils.c b/glib/tests/fileutils.c index 1f6639262..fff421757 100644 --- a/glib/tests/fileutils.c +++ b/glib/tests/fileutils.c @@ -46,7 +46,7 @@ #define S G_DIR_SEPARATOR_S static void -check_string (gchar *str, gchar *expected) +check_string (gchar *str, const gchar *expected) { g_assert (str != NULL); g_assert_cmpstr (str, ==, expected); @@ -825,6 +825,7 @@ test_read_link (void) path = g_file_read_link (oldpath, &error); g_assert_error (error, G_FILE_ERROR, G_FILE_ERROR_INVAL); g_assert_null (path); + g_error_free (error); g_free (cwd); g_free (newpath); diff --git a/glib/tests/option-context.c b/glib/tests/option-context.c index d56eb534a..8cf77a6f0 100644 --- a/glib/tests/option-context.c +++ b/glib/tests/option-context.c @@ -2384,12 +2384,13 @@ short_remaining (void) { NULL } }; GOptionContext* context; - gchar **argv; + gchar **argv, **argv_copy; gint argc; g_test_bug ("729563"); argv = split_string ("program -ri -n 4 -t hello file1 file2", &argc); + argv_copy = copy_stringv (argv, argc); context = g_option_context_new (NULL); @@ -2407,7 +2408,10 @@ short_remaining (void) g_assert_cmpstr (files[1], ==, "file2"); g_assert (files[2] == NULL); - g_strfreev (argv); + g_free (text); + g_strfreev (files); + g_strfreev (argv_copy); + g_free (argv); g_option_context_free (context); }