mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-03-26 11:46:34 +01:00
Merge pull request #59 from redboltz/add_null_check
Added null pointer check.
This commit is contained in:
commit
9eb4583dd5
@ -98,6 +98,7 @@ void msgpack_vrefbuffer_clear(msgpack_vrefbuffer* vref);
|
||||
static inline msgpack_vrefbuffer* msgpack_vrefbuffer_new(size_t ref_size, size_t chunk_size)
|
||||
{
|
||||
msgpack_vrefbuffer* vbuf = (msgpack_vrefbuffer*)malloc(sizeof(msgpack_vrefbuffer));
|
||||
if (vbuf == NULL) return NULL;
|
||||
if(!msgpack_vrefbuffer_init(vbuf, ref_size, chunk_size)) {
|
||||
free(vbuf);
|
||||
return NULL;
|
||||
|
@ -91,6 +91,7 @@ void msgpack_zbuffer_destroy(msgpack_zbuffer* zbuf)
|
||||
msgpack_zbuffer* msgpack_zbuffer_new(int level, size_t init_size)
|
||||
{
|
||||
msgpack_zbuffer* zbuf = (msgpack_zbuffer*)malloc(sizeof(msgpack_zbuffer));
|
||||
if (zbuf == NULL) return NULL;
|
||||
if(!msgpack_zbuffer_init(zbuf, level, init_size)) {
|
||||
free(zbuf);
|
||||
return NULL;
|
||||
|
@ -84,9 +84,12 @@ void* msgpack_zone_malloc_expand(msgpack_zone* zone, size_t size)
|
||||
|
||||
msgpack_zone_chunk* chunk = (msgpack_zone_chunk*)malloc(
|
||||
sizeof(msgpack_zone_chunk) + sz);
|
||||
|
||||
if (chunk == NULL) return NULL;
|
||||
char* ptr = ((char*)chunk) + sizeof(msgpack_zone_chunk);
|
||||
|
||||
if (ptr == NULL) {
|
||||
free(chunk);
|
||||
return NULL;
|
||||
}
|
||||
chunk->next = cl->head;
|
||||
cl->head = chunk;
|
||||
cl->free = sz - size;
|
||||
|
Loading…
x
Reference in New Issue
Block a user