path: root/common/misc.c
diff options
authorCarsten Schlote <>2008-02-20 16:44:34 +0100
committerMarc Kleine-Budde <>2008-02-20 20:41:57 +0100
commit7538c063002864ca5237ba4bbf96174b7057998d (patch)
tree3c8e16f75fc45ce6c37a7feb3b9ee33823297811 /common/misc.c
parent0dd247729a7b59e9b064600ae11981fd31cd3752 (diff)
[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 <>
Diffstat (limited to 'common/misc.c')
1 files changed, 3 insertions, 1 deletions
diff --git a/common/misc.c b/common/misc.c
index 6970ab7e6..920ac4997 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;