Skip to content

Commit

Permalink
Check return value of malloc
Browse files Browse the repository at this point in the history
Signed-off-by: Jianhui Zhao <jianhuizhao329@gmail.com>
  • Loading branch information
Jianhui Zhao committed Jun 18, 2018
1 parent 8365939 commit 09a7fe4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/uwsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ static bool parse_frame(struct uwsc_client *cl, uint8_t *data, uint64_t len)
if (!fin) {
frame->fragmented = true;
frame->payload = malloc(payloadlen);
if (!frame->payload) {
uwsc_log_err("No mem");
cl->send(cl, NULL, 0, WEBSOCKET_OP_CLOSE);
cl->error = UWSC_ERROR_NOMEM;
return false;
}
memcpy(frame->payload, payload, payloadlen);
}
}
Expand Down

0 comments on commit 09a7fe4

Please sign in to comment.