Skip to content

Commit

Permalink
bplist: Make sure to bail out if malloc() fails in parse_string_node()
Browse files Browse the repository at this point in the history
Credit to Wang Junjie <zhunkibatu@gmail.com> (#93)
  • Loading branch information
nikias committed Feb 7, 2017
1 parent 3a5520c commit fbd8494
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/bplist.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit fbd8494

Please sign in to comment.