diff --git a/libc/upstream-dlmalloc/malloc.c b/libc/upstream-dlmalloc/malloc.c index 5e675b459..0a1f6b29f 100644 --- a/libc/upstream-dlmalloc/malloc.c +++ b/libc/upstream-dlmalloc/malloc.c @@ -4049,12 +4049,20 @@ static void* sys_alloc(mstate m, size_t nb) { } 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; + } } /*