summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2017-02-07 12:43:27 +0100
committerGravatar Nikias Bassen2017-02-07 12:43:27 +0100
commitfbd8494d5e4e46bf2e90cb6116903e404374fb56 (patch)
tree13a26772b7f47b0d96455bad371a3a4efc485003 /src
parent3a5520ccce42ac145794f2195cc60e8ae855a8cb (diff)
downloadlibplist-fbd8494d5e4e46bf2e90cb6116903e404374fb56.tar.gz
libplist-fbd8494d5e4e46bf2e90cb6116903e404374fb56.tar.bz2
bplist: Make sure to bail out if malloc() fails in parse_string_node()
Credit to Wang Junjie <zhunkibatu@gmail.com> (#93)
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 81bd716..20e5090 100644
--- a/src/bplist.c
+++ b/src/bplist.c
@@ -289,6 +289,11 @@ static plist_t parse_string_node(const char **bnode, uint64_t size)
data->type = PLIST_STRING;
data->strval = (char *) malloc(sizeof(char) * (size + 1));
+ if (!data->strval) {
+ plist_free_data(data);
+ PLIST_BIN_ERR("%s: Could not allocate %" PRIu64 " bytes\n", __func__, sizeof(char) * (size + 1));
+ return NULL;
+ }
memcpy(data->strval, *bnode, size);
data->strval[size] = '\0';
data->length = strlen(data->strval);