AK: Avoid OOB access in UniformBumpAllocator::destroy_all()

Otherwise we would end up calling T::~T() on some random memory right
after our mapped block, which is most likely a pretty bad thing to do :P
This commit is contained in:
Ali Mohammad Pur 2021-08-13 04:39:11 +04:30
parent 0e5e6f2e08
commit 0f1425c895
Notes: sideshowbarker 2024-07-18 07:03:15 +09:00

View File

@ -163,7 +163,7 @@ public:
{
this->for_each_chunk([&](auto chunk) {
auto base_ptr = align_up_to(chunk + sizeof(typename Allocator::ChunkHeader), alignof(T));
FlatPtr end_offset = this->m_chunk_size;
FlatPtr end_offset = this->m_chunk_size - sizeof(typename Allocator::ChunkHeader);
if (chunk == this->m_current_chunk)
end_offset = this->m_byte_offset_into_current_chunk;
for (; base_ptr - chunk < end_offset; base_ptr += sizeof(T))