diff options
author | Eric Andersen <andersen@codepoet.org> | 2001-01-12 10:53:48 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2001-01-12 10:53:48 +0000 |
commit | ddaf94095891a21cedd6a18d9178e4444fb937a7 (patch) | |
tree | b47bcefa33533e4f41ecce4e3a1bee1d215e006e /libc/stdlib/malloc-simple | |
parent | 77879554671206102471bb282accb3251395d151 (diff) |
Patch from James Graves <jgraves@deltamobile.com> to better handle m68k.
Also fixes 2 very important malloc bugs! Anyone using malloc (esp mmu-less)
should update and recompile.
-Erik
Diffstat (limited to 'libc/stdlib/malloc-simple')
-rw-r--r-- | libc/stdlib/malloc-simple/alloc.c | 6 |
1 files changed, 4 insertions, 2 deletions
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; } |