fix failure of malloc to set errno on heap (brk) exhaustion
authorRich Felker <dalias@aerifal.cx>
Sat, 5 Oct 2013 15:59:21 +0000 (11:59 -0400)
committerRich Felker <dalias@aerifal.cx>
Sat, 5 Oct 2013 15:59:21 +0000 (11:59 -0400)
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.

src/malloc/malloc.c

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