From: Rich Felker Date: Sat, 5 Oct 2013 15:59:21 +0000 (-0400) Subject: fix failure of malloc to set errno on heap (brk) exhaustion X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=a947d317a2769d90bdb19aa11942b7a0680051d5;p=musl fix failure of malloc to set errno on heap (brk) exhaustion I wrongly assumed the brk syscall would set errno, but on failure it returns the old value of the brk rather than an error code. --- diff --git a/src/malloc/malloc.c b/src/malloc/malloc.c index fb65ab5b..d6ad9041 100644 --- a/src/malloc/malloc.c +++ b/src/malloc/malloc.c @@ -177,6 +177,7 @@ static struct chunk *expand_heap(size_t n) return w; fail: unlock(mal.brk_lock); + errno = ENOMEM; return 0; }