Skip to content

Commit

Permalink
Merge pull request #10 from DevShiftTeam/development
Browse files Browse the repository at this point in the history
When freeing first block there was an access to undefined address fix #9
  • Loading branch information
LessComplexity authored Mar 22, 2021
2 parents 85b80df + 5047c69 commit bf42d3a
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions MemoryPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,8 @@ void CPPShift::Memory::MemoryPoolManager::free(void* unit_pointer_start)

// If block offset is 0 remove block if not the only one left
if (mp->currentBlock != mp->firstBlock && (block->offset == 0 || block->numberOfAllocated == block->numberOfDeleted)) {
SMemoryBlockHeader* prev = block->prev;
SMemoryBlockHeader* next = block->next;
prev->next = next;
if (block == mp->firstBlock) mp->firstBlock = block->next;
else block->prev->next = block->next;
if (block == mp->currentBlock) mp->currentBlock = block->prev;
std::free(block);
}
Expand Down

0 comments on commit bf42d3a

Please sign in to comment.