rapidjson
rapidjson copied to clipboard
Need handle allocator allocation failed
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_;
I have added handling. But the users of the allocators have not handled Malloc() == NULL in most cases.