Skip to content

Commit 6d4994f

Browse files
committed
Fix realloc bug in maintenance of prev_free
Fixes #314
1 parent 69d5072 commit 6d4994f

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

mos-platform/common/c/malloc.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -494,10 +494,9 @@ void *realloc(void *ptr, size_t size) {
494494
TRACE("Not enough remainder, so size now %u\n", chunk->size());
495495
} else {
496496
TRACE("Inserting remainder of next chunk.\n");
497-
FreeChunk::insert(chunk->end(), next_size - grow)->prev_free = false;
497+
FreeChunk::insert(chunk->end(), next_size - grow);
498498
}
499-
500-
assert(!chunk->free() && "newly reallocated chunk should not be free");
499+
chunk->set_free(false);
501500
return ptr;
502501
}
503502
}

0 commit comments

Comments
 (0)