From a69dffbc53844ec2b7753fc2b7d9ac0144e1fca9 Mon Sep 17 00:00:00 2001 From: Koji Kobayashi Date: Wed, 10 Sep 2014 20:35:23 -0700 Subject: [PATCH] make MemoryPoolAllocator's Malloc work after Clear if a buffer was not supplied by the user --- include/rapidjson/allocators.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/rapidjson/allocators.h b/include/rapidjson/allocators.h index 6597a9d..73e56eb 100644 --- a/include/rapidjson/allocators.h +++ b/include/rapidjson/allocators.h @@ -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(chunkHead_ + 1) + chunkHead_->size;