[fix](memory) fix bug that ~BitShufflePageDecoder destroys uninitialized chunk (#7172)

Added a safe way to destroy Chunk.
This commit is contained in:
Xinyi Zou
2021-11-23 15:24:25 +08:00
committed by GitHub
parent ce7fa5d6d9
commit ad0d2b82ab
3 changed files with 7 additions and 7 deletions

View File

@ -170,6 +170,9 @@ bool ChunkAllocator::allocate(size_t size, Chunk* chunk) {
}
void ChunkAllocator::free(const Chunk& chunk) {
if (chunk.core_id == -1) {
return;
}
int64_t old_reserved_bytes = _reserved_bytes;
int64_t new_reserved_bytes = 0;
do {
@ -190,7 +193,6 @@ void ChunkAllocator::free(const Chunk& chunk) {
_arenas[chunk.core_id]->push_free_chunk(chunk.data, chunk.size);
}
bool ChunkAllocator::allocate_align(size_t size, Chunk* chunk) {
return allocate(BitUtil::RoundUpToPowerOfTwo(size), chunk);
}