diff options
author | Nikias Bassen | 2022-01-28 23:45:56 +0100 |
---|---|---|
committer | Nikias Bassen | 2022-01-28 23:46:25 +0100 |
commit | ea8933136125d07077a97c177580f93cc8c41034 (patch) | |
tree | 83ec37e452a7d93e157e7fb5020fea7bbd1d0078 /src/jplist.c | |
parent | 088cdab964e6cd88b7f15f36eb3e08d38189cd21 (diff) | |
download | libplist-ea8933136125d07077a97c177580f93cc8c41034.tar.gz libplist-ea8933136125d07077a97c177580f93cc8c41034.tar.bz2 |
jplist: Fix a few memory leaks that occur when parsing fails
Credit to OSS-Fuzz
Diffstat (limited to 'src/jplist.c')
-rw-r--r-- | src/jplist.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/jplist.c b/src/jplist.c index c149d20..88cce28 100644 --- a/src/jplist.c +++ b/src/jplist.c @@ -596,6 +596,9 @@ static plist_t parse_array(const char* js, jsmntok_t* tokens, int* index) } if (val) { plist_array_append_item(arr, val); + } else { + plist_free(arr); + return NULL; } } *(index) = j; @@ -616,6 +619,7 @@ static plist_t parse_object(const char* js, jsmntok_t* tokens, int* index) if (tokens[j].type == JSMN_STRING) { char* key = unescape_string(js + tokens[j].start, tokens[j].end - tokens[j].start, NULL); if (!key) { + plist_free(obj); return NULL; } plist_t val = NULL; @@ -643,6 +647,7 @@ static plist_t parse_object(const char* js, jsmntok_t* tokens, int* index) free(key); } else { PLIST_JSON_ERR("%s: keys must be of type STRING\n", __func__); + plist_free(obj); return NULL; } } |