From d7758c07ec8200d20c68384b291ca9e948802e92 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Wed, 2 Feb 2022 04:45:40 +0100 Subject: jplist: Fix memory leak on parse error Credit to OSS-Fuzz --- src/jplist.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/jplist.c') diff --git a/src/jplist.c b/src/jplist.c index 1629f59..c2d3ae3 100644 --- a/src/jplist.c +++ b/src/jplist.c @@ -634,6 +634,7 @@ static plist_t parse_array(const char* js, jsmntok_info_t* ti, int* index) for (num = 0; num < num_tokens; num++) { if (j >= ti->count) { PLIST_JSON_ERR("%s: token index out of valid range\n", __func__); + plist_free(arr); return NULL; } plist_t val = NULL; @@ -677,6 +678,7 @@ static plist_t parse_object(const char* js, jsmntok_info_t* ti, int* index) for (num = 0; num < num_tokens; num++) { if (j >= ti->count) { PLIST_JSON_ERR("%s: token index out of valid range\n", __func__); + plist_free(obj); return NULL; } if (ti->tokens[j].type == JSMN_STRING) { -- cgit v1.1-32-gdbae