mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-10-21 23:56:55 +02:00
Move overflow check up
This commit is contained in:
@@ -30,6 +30,10 @@ bool msgpack_vrefbuffer_init(msgpack_vrefbuffer* vbuf,
|
||||
ref_size > MSGPACK_PACKER_MAX_BUFFER_SIZE + 1 ?
|
||||
ref_size : MSGPACK_PACKER_MAX_BUFFER_SIZE + 1 ;
|
||||
|
||||
if((sizeof(msgpack_vrefbuffer_chunk) + chunk_size) < chunk_size) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nfirst = (sizeof(struct iovec) < 72/2) ?
|
||||
72 / sizeof(struct iovec) : 8;
|
||||
|
||||
@@ -43,11 +47,6 @@ bool msgpack_vrefbuffer_init(msgpack_vrefbuffer* vbuf,
|
||||
vbuf->end = array + nfirst;
|
||||
vbuf->array = array;
|
||||
|
||||
if((sizeof(msgpack_vrefbuffer_chunk) + chunk_size) < chunk_size){
|
||||
free(array);
|
||||
return false;
|
||||
}
|
||||
|
||||
chunk = (msgpack_vrefbuffer_chunk*)malloc(
|
||||
sizeof(msgpack_vrefbuffer_chunk) + chunk_size);
|
||||
if(chunk == NULL) {
|
||||
|
Reference in New Issue
Block a user