Преглед на файлове

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.
Rich Felker преди 11 години
родител
ревизия
a947d317a2
променени са 1 файла, в които са добавени 1 реда и са изтрити 0 реда
  1. 1 0
      src/malloc/malloc.c

+ 1 - 0
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;
 }