X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;ds=inline;f=common%2Fdlmalloc.c;h=e9bab09b8eac7c0ec4900a3685f15a807b448c31;hb=11e238d6e672ac8b81cabbc7921b0da5554efc3a;hp=4871f4b0990457a47732abe3c51f3f54a132f2e3;hpb=d963e84c92a63b4e6c4f2f80482a5ecbe9b24fe0;p=u-boot diff --git a/common/dlmalloc.c b/common/dlmalloc.c index 4871f4b099..e9bab09b8e 100644 --- a/common/dlmalloc.c +++ b/common/dlmalloc.c @@ -1511,6 +1511,13 @@ void *sbrk(ptrdiff_t increment) ulong old = mem_malloc_brk; ulong new = old + increment; + /* + * if we are giving memory back make sure we clear it out since + * we set MORECORE_CLEARS to 1 + */ + if (increment < 0) + memset((void *)new, 0, -increment); + if ((new < mem_malloc_start) || (new > mem_malloc_end)) return (void *)MORECORE_FAILURE;