rapidjson icon indicating copy to clipboard operation
rapidjson copied to clipboard

Need handle allocator allocation failed

Open vominh2012 opened this issue 10 years ago • 1 comments

I see that in AddChunk function in class MemoryPoolAllocator does not handle the case when allocation failed. The code below will crash application when chunk = NULL.

ChunkHeader* chunk = reinterpret_cast<ChunkHeader*>(baseAllocator_->Malloc(RAPIDJSON_ALIGN(sizeof(ChunkHeader)) + capacity)); chunk->capacity = capacity; chunk->size = 0; chunk->next = chunkHead_;

vominh2012 avatar Jul 14 '16 03:07 vominh2012

I have added handling. But the users of the allocators have not handled Malloc() == NULL in most cases.

miloyip avatar Jul 23 '16 02:07 miloyip