From 7538c063002864ca5237ba4bbf96174b7057998d Mon Sep 17 00:00:00 2001 From: Carsten Schlote Date: Wed, 20 Feb 2008 16:44:34 +0100 Subject: [general] Fixed crash in memory allocator Fixed a bug in sbrk(). When the new mem_brk value returned by sbrk_no_zero() returns NULL to indicate 'out of memory', sbrk() still memset()s innocent memory at address NULL. For some architectures this memory might be empty, so this never causes a problem. Anyway on Coldfire I still have my vector table there. Nuking them isn't really a good idea :-) Signed-off-by: Carsten Schlote --- common/misc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'common/misc.c') diff --git a/common/misc.c b/common/misc.c index 6970ab7e6e..920ac49978 100644 --- a/common/misc.c +++ b/common/misc.c @@ -64,7 +64,9 @@ void *sbrk (ptrdiff_t increment) { void *old = sbrk_no_zero(increment); - memset (old, 0, increment); + /* Only clear increment, if valid address was returned */ + if (old != NULL) + memset (old, 0, increment); return old; } -- cgit v1.2.3