summaryrefslogtreecommitdiffstats
path: root/common/misc.c
diff options
context:
space:
mode:
authorCarsten Schlote <c.schlote@konzeptpark.de>2008-02-20 16:44:34 +0100
committerMarc Kleine-Budde <mkl@pengutronix.de>2008-02-20 20:41:57 +0100
commit7538c063002864ca5237ba4bbf96174b7057998d (patch)
tree3c8e16f75fc45ce6c37a7feb3b9ee33823297811 /common/misc.c
parent0dd247729a7b59e9b064600ae11981fd31cd3752 (diff)
downloadbarebox-7538c063002864ca5237ba4bbf96174b7057998d.tar.gz
[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 <c.schlote@konzeptpark.de>
Diffstat (limited to 'common/misc.c')
-rw-r--r--common/misc.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/common/misc.c b/common/misc.c
index 6970ab7..920ac49 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;
}