commit bc9c794edc814f0b6d59723b48811deba258046d
parent 48519b9c63ac9fb07d4f00261ad77afa6f1990af
Author: Drew DeVault <sir@cmpwn.com>
Date: Fri, 12 Feb 2021 14:34:23 -0500
rt::realloc: free on zero size
Diffstat:
1 file changed, 1 insertion(+), 0 deletions(-)
diff --git a/rt/malloc.ha b/rt/malloc.ha
@@ -145,6 +145,7 @@ fn free_small(p: *void, s: size) void = {
// request.
export fn realloc(_p: nullable *void, n: size) nullable *void = {
if (n == 0) {
+ free_(_p);
return null;
} else if (_p == null) {
return malloc(n);