From ddaf94095891a21cedd6a18d9178e4444fb937a7 Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Fri, 12 Jan 2001 10:53:48 +0000 Subject: Patch from James Graves to better handle m68k. Also fixes 2 very important malloc bugs! Anyone using malloc (esp mmu-less) should update and recompile. -Erik --- libc/stdlib/malloc-simple/alloc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'libc/stdlib/malloc-simple/alloc.c') diff --git a/libc/stdlib/malloc-simple/alloc.c b/libc/stdlib/malloc-simple/alloc.c index f31105d4e..f278a9583 100644 --- a/libc/stdlib/malloc-simple/alloc.c +++ b/libc/stdlib/malloc-simple/alloc.c @@ -99,10 +99,12 @@ void *realloc(void *ptr, size_t size) if (size > 0) { newptr = malloc(size); - if (newptr && ptr) + if (newptr && ptr) { memcpy(newptr, ptr, size); + free(ptr); + } } - if (ptr) + else free(ptr); return newptr; } -- cgit v1.2.3