summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2022-02-02 04:45:40 +0100
committerGravatar Nikias Bassen2022-02-02 04:45:40 +0100
commitd7758c07ec8200d20c68384b291ca9e948802e92 (patch)
tree9857ac8a015872584d0c04cc4a235b7e0d56c779 /src
parent474c8eb82e776bfac804338247045b11fa389d8d (diff)
downloadlibplist-d7758c07ec8200d20c68384b291ca9e948802e92.tar.gz
libplist-d7758c07ec8200d20c68384b291ca9e948802e92.tar.bz2
jplist: Fix memory leak on parse error
Credit to OSS-Fuzz
Diffstat (limited to 'src')
-rw-r--r--src/jplist.c2
1 files changed, 2 insertions, 0 deletions
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)
634 for (num = 0; num < num_tokens; num++) { 634 for (num = 0; num < num_tokens; num++) {
635 if (j >= ti->count) { 635 if (j >= ti->count) {
636 PLIST_JSON_ERR("%s: token index out of valid range\n", __func__); 636 PLIST_JSON_ERR("%s: token index out of valid range\n", __func__);
637 plist_free(arr);
637 return NULL; 638 return NULL;
638 } 639 }
639 plist_t val = NULL; 640 plist_t val = NULL;
@@ -677,6 +678,7 @@ static plist_t parse_object(const char* js, jsmntok_info_t* ti, int* index)
677 for (num = 0; num < num_tokens; num++) { 678 for (num = 0; num < num_tokens; num++) {
678 if (j >= ti->count) { 679 if (j >= ti->count) {
679 PLIST_JSON_ERR("%s: token index out of valid range\n", __func__); 680 PLIST_JSON_ERR("%s: token index out of valid range\n", __func__);
681 plist_free(obj);
680 return NULL; 682 return NULL;
681 } 683 }
682 if (ti->tokens[j].type == JSMN_STRING) { 684 if (ti->tokens[j].type == JSMN_STRING) {