[systemd-commits] src/shared src/test

Thomas H.P. Andersen phomes at kemper.freedesktop.org
Tue May 19 14:20:02 PDT 2015


 src/shared/json.c    |    2 +-
 src/test/test-json.c |    4 +---
 2 files changed, 2 insertions(+), 4 deletions(-)

New commits:
commit fecb719ec1e1abc665f91d55adaa4951db5c1bed
Author: Thomas Hindoe Paaboel Andersen <phomes at gmail.com>
Date:   Tue May 19 23:19:29 2015 +0200

    json: fix a mem leak

diff --git a/src/shared/json.c b/src/shared/json.c
index f6c44f4..5d7d0db 100644
--- a/src/shared/json.c
+++ b/src/shared/json.c
@@ -126,7 +126,7 @@ JsonVariant *json_variant_unref(JsonVariant *variant) {
                 return NULL;
 
         if (variant->type == JSON_VARIANT_ARRAY || variant->type == JSON_VARIANT_OBJECT)
-                return json_object_unref(variant);
+                json_object_unref(variant);
 
         else if (variant->type == JSON_VARIANT_STRING)
                 free(variant->string);
diff --git a/src/test/test-json.c b/src/test/test-json.c
index c4b4a22..0be69f8 100644
--- a/src/test/test-json.c
+++ b/src/test/test-json.c
@@ -75,7 +75,7 @@ static void test_one(const char *data, ...) {
 typedef void (*Test)(JsonVariant *);
 
 static void test_file(const char *data, Test test) {
-        JsonVariant *v = NULL;
+        _cleanup_jsonunref_ JsonVariant *v = NULL;
         int r = json_parse(data, &v);
 
         assert_se(r == 0);
@@ -84,8 +84,6 @@ static void test_file(const char *data, Test test) {
 
         if (test)
                 test(v);
-
-        json_variant_unref(v);
 }
 
 static void test_1(JsonVariant *v) {



More information about the systemd-commits mailing list