summaryrefslogtreecommitdiffstats
path: root/src/jplist.c
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2026-02-12 01:20:05 +0100
committerGravatar Nikias Bassen2026-02-12 01:20:05 +0100
commit4e82bc85671cfe50763de2637b54cb8576d7976f (patch)
tree378d7d8c51e9a6a618e0f45aa6edf97e56bd3c1c /src/jplist.c
parent8c78d89041b713bffcb0b09fee4468304a3a54d5 (diff)
downloadlibplist-4e82bc85671cfe50763de2637b54cb8576d7976f.tar.gz
libplist-4e82bc85671cfe50763de2637b54cb8576d7976f.tar.bz2
Add NULL checks across codebase
Diffstat (limited to 'src/jplist.c')
-rw-r--r--src/jplist.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/jplist.c b/src/jplist.c
index 2c88756..2bb526e 100644
--- a/src/jplist.c
+++ b/src/jplist.c
@@ -540,6 +540,10 @@ static plist_t parse_primitive(const char* js, jsmntok_info_t* ti, int* index)
540 val = plist_new_bool(1); 540 val = plist_new_bool(1);
541 } else if (!strncmp("null", str_val, str_len)) { 541 } else if (!strncmp("null", str_val, str_len)) {
542 plist_data_t data = plist_new_plist_data(); 542 plist_data_t data = plist_new_plist_data();
543 if (!data) {
544 PLIST_JSON_ERR("%s: failed to allocate plist data\n", __func__);
545 return NULL;
546 }
543 data->type = PLIST_NULL; 547 data->type = PLIST_NULL;
544 val = plist_new_node(data); 548 val = plist_new_node(data);
545 } else if (isdigit(str_val[0]) || (str_val[0] == '-' && str_val+1 < str_end && isdigit(str_val[1]))) { 549 } else if (isdigit(str_val[0]) || (str_val[0] == '-' && str_val+1 < str_end && isdigit(str_val[1]))) {
@@ -598,6 +602,10 @@ static plist_t parse_primitive(const char* js, jsmntok_info_t* ti, int* index)
598 } else { 602 } else {
599 PLIST_JSON_ERR("%s: invalid primitive value '%.*s' encountered\n", __func__, (int)str_len, str_val); 603 PLIST_JSON_ERR("%s: invalid primitive value '%.*s' encountered\n", __func__, (int)str_len, str_val);
600 } 604 }
605 if (!val) {
606 PLIST_JSON_ERR("%s: failed to create node\n", __func__);
607 return NULL;
608 }
601 (*index)++; 609 (*index)++;
602 return val; 610 return val;
603} 611}
@@ -695,10 +703,20 @@ static plist_t parse_string(const char* js, jsmntok_info_t* ti, int* index)
695 plist_t node; 703 plist_t node;
696 704
697 plist_data_t data = plist_new_plist_data(); 705 plist_data_t data = plist_new_plist_data();
706 if (!data) {
707 free(strval);
708 PLIST_JSON_ERR("%s: failed to allocate plist data\n", __func__);
709 return NULL;
710 }
698 data->type = PLIST_STRING; 711 data->type = PLIST_STRING;
699 data->strval = strval; 712 data->strval = strval;
700 data->length = str_len; 713 data->length = str_len;
701 node = plist_new_node(data); 714 node = plist_new_node(data);
715 if (!node) {
716 plist_free_data(data);
717 PLIST_JSON_ERR("%s: failed to create node\n", __func__);
718 return NULL;
719 }
702 720
703 (*index)++; 721 (*index)++;
704 return node; 722 return node;