mirror of
https://github.com/clearlinux/systemd-stable.git
synced 2026-10-03 23:38:39 +00:00
json: fix a mem leak
This commit is contained in:
+1
-1
@@ -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);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user