make MemoryPoolAllocator's Malloc work after Clear if a buffer was not supplied by the user

This commit is contained in:
Koji Kobayashi 2014-09-10 20:35:23 -07:00
parent a5ffc5be1c
commit a69dffbc53

View File

@ -170,7 +170,7 @@ public:
//! Allocates a memory block. (concept Allocator)
void* Malloc(size_t size) {
size = RAPIDJSON_ALIGN(size);
if (chunkHead_->size + size > chunkHead_->capacity)
if (chunkHead_ == 0 || chunkHead_->size + size > chunkHead_->capacity)
AddChunk(chunk_capacity_ > size ? chunk_capacity_ : size);
void *buffer = reinterpret_cast<char *>(chunkHead_ + 1) + chunkHead_->size;