Follow on to previous change
If sbrk is shrinking the heap memory size, skip memset (otherwise it would
treat the negative value as a very large positive one and clobber memory).
@@ -22,6 +22,8 @@ volatile unsigned int next_alloc = 0x500000;
void *sbrk(ptrdiff_t size)
{
void *base_ptr = (void*) __sync_fetch_and_add(&next_alloc, size);
+ if (size > 0)
memset(base_ptr, 0, size);
+
return base_ptr;
}
