mirror of
https://github.com/justinian/jsix.git
synced 2025-12-11 08:54:31 -08:00
[kernel] Fix freelist-clobber bug in heap allocator
The heap_allocator::get_free(order) function returns a reference to the head pointer of the given freelist, so that it can be manipulated. However, split_off was also taking a reference to a pointer for an out param - passing the freelist pointer in here caused split_off to modify the freelist. I cleaned up a bunch of the places the freelist pointers were being touched to make the usage more explicit.
This commit is contained in:
@@ -88,9 +88,9 @@ protected:
|
||||
/// Helper to get a block of the given order by splitting existing
|
||||
/// larger blocks. Returns false if there were no larger blocks.
|
||||
/// \arg order Order (2^N) of the block we want
|
||||
/// \arg block [out] Receives a pointer to the requested block
|
||||
/// \arg split [out] Receives a pointer to the requested block
|
||||
/// \returns True if a split was done
|
||||
bool split_off(unsigned order, free_header *&block);
|
||||
bool split_off(unsigned order, free_header *&split);
|
||||
|
||||
uintptr_t m_start, m_end;
|
||||
size_t m_maxsize;
|
||||
|
||||
Reference in New Issue
Block a user