9
0
Fork 0

[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>
This commit is contained in:
Carsten Schlote 2008-02-20 16:44:34 +01:00 committed by Marc Kleine-Budde
parent 0dd247729a
commit 7538c06300
1 changed files with 3 additions and 1 deletions

View File

@ -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;
}