Skip to content

Commit e07e872

Browse files
committed
BugFix: HEAP_MALLOC_FREE_MERGE_NEIGHBOURS has bad code and wasn't getting triggered
1 parent c7cbbc0 commit e07e872

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/usr/lib/stdlib.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -315,16 +315,16 @@ static inline union heap_entry *heap_freeblocks_merge(union heap_entry *node) {
315315
// after : [prev + node + next]
316316

317317
union heap_entry *prev = heap_prev_block(node);
318-
union heap_entry *next = heap_prev_block(node);
319-
if (prev == HEAP_BLOCK_FREE) {
318+
union heap_entry *next = heap_next_block(node);
319+
if (prev->content.state == HEAP_BLOCK_FREE) {
320320
// merge
321321
prev->content.size += node->content.size;
322322
next->content.prev_size = prev->content.size;
323323
node = prev;
324324
}
325-
if (next == HEAP_BLOCK_FREE) {
325+
if (next->content.state == HEAP_BLOCK_FREE) {
326326
// merge
327-
union heap_entry *next_2 = heap_prev_block(next);
327+
union heap_entry *next_2 = heap_next_block(next);
328328
node->content.size += next->content.size;
329329
next_2->content.prev_size = node->content.size;
330330
}

0 commit comments

Comments
 (0)