From: Lennart Poettering Date: Mon, 20 May 2019 14:15:40 +0000 (+0200) Subject: json: fix minor memory leak on error path X-Git-Tag: v243-rc1~406 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6980b04fb608f2f23b697d6a5e60017881f46388;p=thirdparty%2Fsystemd.git json: fix minor memory leak on error path --- diff --git a/src/shared/json.c b/src/shared/json.c index 073f800b346..782d80af16a 100644 --- a/src/shared/json.c +++ b/src/shared/json.c @@ -2296,9 +2296,9 @@ static int json_parse_internal( column = &column_buffer; for (;;) { + _cleanup_(json_variant_unrefp) JsonVariant *add = NULL; _cleanup_free_ char *string = NULL; unsigned line_token, column_token; - JsonVariant *add = NULL; JsonStack *current; JsonValue value; int token; @@ -2591,7 +2591,7 @@ static int json_parse_internal( goto finish; } - current->elements[current->n_elements++] = add; + current->elements[current->n_elements++] = TAKE_PTR(add); } }