mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-10-23 16:48:07 +02:00
Added null pointer check for C++ separated code.
This commit is contained in:
@@ -230,8 +230,13 @@ inline void* zone::allocate_expand(size_t size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
chunk* c = static_cast<chunk*>(::malloc(sizeof(chunk) + sz));
|
chunk* c = static_cast<chunk*>(::malloc(sizeof(chunk) + sz));
|
||||||
|
if (!c) return nullptr;
|
||||||
|
|
||||||
char* ptr = reinterpret_cast<char*>(c) + sizeof(chunk);
|
char* ptr = reinterpret_cast<char*>(c) + sizeof(chunk);
|
||||||
|
if (!ptr) {
|
||||||
|
::free(c);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
c->next_ = cl->head_;
|
c->next_ = cl->head_;
|
||||||
cl->head_ = c;
|
cl->head_ = c;
|
||||||
|
Reference in New Issue
Block a user