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.
This commit is contained in:
Rich Felker
2013-10-05 11:59:21 -04:00
parent 5437870390
commit a947d317a2

View File

@ -177,6 +177,7 @@ static struct chunk *expand_heap(size_t n)
return w;
fail:
unlock(mal.brk_lock);
errno = ENOMEM;
return 0;
}