Add missing MALLOC_FAILURE_ACTION calls to dlmalloc.
Without these, sometimes malloc(3) returns NULL without setting errno.
Change-Id: I4708c3f675bf2c878ddcaf012fde7848b255826b
diff --git a/libc/upstream-dlmalloc/malloc.c b/libc/upstream-dlmalloc/malloc.c
index 5e675b4..0a1f6b2 100644
--- a/libc/upstream-dlmalloc/malloc.c
+++ b/libc/upstream-dlmalloc/malloc.c
@@ -4049,12 +4049,20 @@
}
asize = granularity_align(nb + SYS_ALLOC_PADDING);
- if (asize <= nb)
+ if (asize <= nb) {
+ /* BEGIN android-added: set errno */
+ MALLOC_FAILURE_ACTION;
+ /* END android-added */
return 0; /* wraparound */
+ }
if (m->footprint_limit != 0) {
size_t fp = m->footprint + asize;
- if (fp <= m->footprint || fp > m->footprint_limit)
+ if (fp <= m->footprint || fp > m->footprint_limit) {
+ /* BEGIN android-added: set errno */
+ MALLOC_FAILURE_ACTION;
+ /* END android-added */
return 0;
+ }
}
/*