summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2017-02-07 12:49:58 +0100
committerGravatar Nikias Bassen2017-02-07 12:49:58 +0100
commit07e92dd116ed08ec8fc12cae6e48d7f2146aec53 (patch)
tree2b2bf6640c22fc58eef1adfa0600a2bd6f51f299 /src
parent56ba9bf7f625f6b72df982e7ef298b9791b1cf47 (diff)
downloadlibplist-07e92dd116ed08ec8fc12cae6e48d7f2146aec53.tar.gz
libplist-07e92dd116ed08ec8fc12cae6e48d7f2146aec53.tar.bz2
bplist: Make sure to bail out if malloc() fails in parse_unicode_node()
Credit to OSS-Fuzz
Diffstat (limited to 'src')
-rw-r--r--src/bplist.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/bplist.c b/src/bplist.c
index c1f6007..640a5c0 100644
--- a/src/bplist.c
+++ b/src/bplist.c
@@ -368,6 +368,11 @@ static plist_t parse_unicode_node(const char **bnode, uint64_t size)
data->type = PLIST_STRING;
unicodestr = (uint16_t*) malloc(sizeof(uint16_t) * size);
+ if (!unicodestr) {
+ plist_free_data(data);
+ PLIST_BIN_ERR("%s: Could not allocate %" PRIu64 " bytes\n", __func__, sizeof(uint16_t) * size);
+ return NULL;
+ }
for (i = 0; i < size; i++)
unicodestr[i] = be16toh(((uint16_t*)*bnode)[i]);