summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Withnall <withnall@endlessm.com>2017-12-15 16:23:50 +0000
committerEmmanuele Bassi <ebassi@gnome.org>2018-03-13 11:15:55 +0000
commit58dd18e0629690c80ac4b00bb98a693d9895ff21 (patch)
tree631759c629903289c6f89610476cf96660a8d74a
parent15304031d6324123b6dfb120bdac344ed9f165f7 (diff)
downloadjson-glib-58dd18e0629690c80ac4b00bb98a693d9895ff21.tar.gz
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 (cherry picked from commit 43b9703970a6d5f2fc53f828ab8d29195ab01583) Signed-off-by: Emmanuele Bassi <ebassi@gnome.org>
-rw-r--r--json-glib/tests/path.c1
-rw-r--r--json-glib/tests/reader.c2
-rw-r--r--json-glib/tests/serialize-complex.c3
3 files changed, 5 insertions, 1 deletions
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