Skip to content

Commit 285c320

Browse files
authored
Merge pull request #1937 from grumpycoders/realloc-fix
Fixing realloc's edge case.
2 parents a68a3dd + 35de25b commit 285c320

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/mips/openbios/kernel/alloc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,8 @@ static __attribute__((section(".ramtext"))) void *multi_realloc(void *ptr_, size
267267
} else {
268268
// Otherwise, we need to create a new empty block after what we are re-allocating.
269269
empty_block *new_block = (empty_block *)((char *)block + size);
270-
new_block->next = head;
271-
new_block->size = delta;
270+
new_block->next = head->next;
271+
new_block->size = head->size - delta;
272272
if (heap == HEAP_USER) {
273273
user_heap_head = new_block;
274274
} else {

src/mips/psyqo/src/alloc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -548,8 +548,8 @@ void *psyqo_realloc(void *ptr_, size_t size_) {
548548
} else {
549549
// Otherwise, we need to create a new empty block after what we are re-allocating.
550550
empty_block *new_block = (empty_block *)((char *)block + size);
551-
new_block->next = head;
552-
new_block->size = delta;
551+
new_block->next = head->next;
552+
new_block->size = head->size - delta;
553553
head = new_block;
554554
}
555555
block->size = size;

0 commit comments

Comments
 (0)