mirror of
https://github.com/nghttp2/nghttp2.git
synced 2025-12-08 11:08:52 +08:00
Fix 0 size malloc
This commit is contained in:
@@ -366,9 +366,14 @@ ssize_t nghttp2_bufs_remove(nghttp2_bufs *bufs, uint8_t **out)
|
|||||||
len += nghttp2_buf_len(&chain->buf);
|
len += nghttp2_buf_len(&chain->buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
res = malloc(len);
|
if(!len) {
|
||||||
if(res == NULL) {
|
res = NULL;
|
||||||
return NGHTTP2_ERR_NOMEM;
|
} else {
|
||||||
|
res = malloc(len);
|
||||||
|
|
||||||
|
if(res == NULL) {
|
||||||
|
return NGHTTP2_ERR_NOMEM;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nghttp2_buf_wrap_init(&resbuf, res, len);
|
nghttp2_buf_wrap_init(&resbuf, res, len);
|
||||||
|
|||||||
@@ -671,14 +671,18 @@ int nghttp2_frame_unpack_goaway_payload2(nghttp2_goaway *frame,
|
|||||||
|
|
||||||
payloadlen -= var_gift_payloadlen;
|
payloadlen -= var_gift_payloadlen;
|
||||||
|
|
||||||
var_gift_payload = malloc(var_gift_payloadlen);
|
if(!var_gift_payloadlen) {
|
||||||
|
var_gift_payload = NULL;
|
||||||
|
} else {
|
||||||
|
var_gift_payload = malloc(var_gift_payloadlen);
|
||||||
|
|
||||||
if(var_gift_payload == NULL) {
|
if(var_gift_payload == NULL) {
|
||||||
return NGHTTP2_ERR_NOMEM;
|
return NGHTTP2_ERR_NOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(var_gift_payload, payload + 8, var_gift_payloadlen);
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(var_gift_payload, payload + 8, var_gift_payloadlen);
|
|
||||||
|
|
||||||
nghttp2_frame_unpack_goaway_payload(frame, payload, payloadlen,
|
nghttp2_frame_unpack_goaway_payload(frame, payload, payloadlen,
|
||||||
var_gift_payload, var_gift_payloadlen);
|
var_gift_payload, var_gift_payloadlen);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user