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)
val = plist_new_bool(1);
} else if (!strncmp("null", str_val, str_len)) {
plist_data_t data = plist_new_plist_data();
+ if (!data) {
+ PLIST_JSON_ERR("%s: failed to allocate plist data\n", __func__);
+ return NULL;
+ }
data->type = PLIST_NULL;
val = plist_new_node(data);
} 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)
} else {
PLIST_JSON_ERR("%s: invalid primitive value '%.*s' encountered\n", __func__, (int)str_len, str_val);
}
+ if (!val) {
+ PLIST_JSON_ERR("%s: failed to create node\n", __func__);
+ return NULL;
+ }
(*index)++;
return val;
}
@@ -695,10 +703,20 @@ static plist_t parse_string(const char* js, jsmntok_info_t* ti, int* index)
plist_t node;
plist_data_t data = plist_new_plist_data();
+ if (!data) {
+ free(strval);
+ PLIST_JSON_ERR("%s: failed to allocate plist data\n", __func__);
+ return NULL;
+ }
data->type = PLIST_STRING;
data->strval = strval;
data->length = str_len;
node = plist_new_node(data);
+ if (!node) {
+ plist_free_data(data);
+ PLIST_JSON_ERR("%s: failed to create node\n", __func__);
+ return NULL;
+ }
(*index)++;
return node;