shithub: scc

Download patch

ref: 1acd5b871784b694808522b487b9dedea67068a2
parent: d58f3f2eb9cb620b8746ff9f7b6c172a91720629
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Tue Mar 29 12:28:06 EDT 2022

libc: Readjust freep realloc() modifies the free list

Freep can be pointing to the block that is modified by
realloc(), so it is needed to set freep to some valid
value (the actual value is not important).

--- a/src/libc/stdlib/realloc.c
+++ b/src/libc/stdlib/realloc.c
@@ -45,6 +45,7 @@
 		if (avail == nunits) {
 			oh->h.size = nunits;
 			prev->h.next = next->h.next;
+			_freep = prev;
 			return ptr;
 		}