[json-glib: 2/3] tests: Fix some memory leaks in the tests



commit 43b9703970a6d5f2fc53f828ab8d29195ab01583
Author: Philip Withnall <withnall endlessm com>
Date:   Fri Dec 15 16:23:50 2017 +0000

    tests: Fix some memory leaks in the tests
    
    We can’t do this by porting to g_autoptr(), because json-glib needs to
    be buildable using MSVC. Sad panda.
    
    Signed-off-by: Philip Withnall <withnall endlessm com>
    
    https://gitlab.gnome.org/GNOME/json-glib/issues/30

 json-glib/tests/path.c              | 1 +
 json-glib/tests/reader.c            | 2 ++
 json-glib/tests/serialize-complex.c | 3 ++-
 3 files changed, 5 insertions(+), 1 deletion(-)
---
diff --git a/json-glib/tests/path.c b/json-glib/tests/path.c
index 0dce631..e6d82c2 100644
--- a/json-glib/tests/path.c
+++ b/json-glib/tests/path.c
@@ -215,6 +215,7 @@ path_expressions_invalid (gconstpointer data)
   g_assert_error (error, JSON_PATH_ERROR, code);
 
   g_object_unref (path);
+  g_clear_error (&error);
 }
 
 static void
diff --git a/json-glib/tests/reader.c b/json-glib/tests/reader.c
index 9bab312..d0a046b 100644
--- a/json-glib/tests/reader.c
+++ b/json-glib/tests/reader.c
@@ -133,6 +133,8 @@ test_base_array (void)
   g_assert (json_reader_get_error (reader) == NULL);
 
   g_object_unref (reader);
+  g_object_unref (parser);
+  g_clear_error (&error);
 }
 
 static void
diff --git a/json-glib/tests/serialize-complex.c b/json-glib/tests/serialize-complex.c
index 9da8dd1..226e722 100644
--- a/json-glib/tests/serialize-complex.c
+++ b/json-glib/tests/serialize-complex.c
@@ -263,7 +263,7 @@ test_serialize (void)
                                   "baz", "Hello, World!",
                                   "meh", 0.5,
                                   NULL);
-  JsonParser *parser = json_parser_new ();
+  JsonParser *parser = NULL;
   GError *error = NULL;
   JsonObject *object;
   JsonNode *node;
@@ -295,6 +295,7 @@ test_serialize (void)
   g_free (data);
   g_object_unref (parser);
   g_object_unref (obj);
+  g_clear_error (&error);
 }
 
 int


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