Added null pointer check for C++ separated code.

This commit is contained in:
Takatoshi Kondo
2014-02-02 17:28:33 +00:00
parent beebccd323
commit 6515577dc3

View File

@@ -230,8 +230,13 @@ inline void* zone::allocate_expand(size_t size)
}
chunk* c = static_cast<chunk*>(::malloc(sizeof(chunk) + sz));
if (!c) return nullptr;
char* ptr = reinterpret_cast<char*>(c) + sizeof(chunk);
if (!ptr) {
::free(c);
return nullptr;
}
c->next_ = cl->head_;
cl->head_ = c;