Fix error

This commit is contained in:
Alexey Milovidov 2023-11-21 23:53:14 +01:00
parent 84f669c113
commit dd54c7e224

View File

@ -176,10 +176,11 @@ public:
}
/// Get piece of memory, without alignment.
/// Note: we expect it will return a non-nullptr even if the size is zero.
char * alloc(size_t size)
{
used_bytes += size;
if (unlikely(static_cast<std::ptrdiff_t>(size) > head.end - head.pos))
if (unlikely(head.empty() || static_cast<std::ptrdiff_t>(size) > head.end - head.pos))
addMemoryChunk(size);
char * res = head.pos;