Add missing MALLOC_FAILURE_ACTION calls to dlmalloc.

Without these, sometimes malloc(3) returns NULL without setting errno.

Change-Id: I4708c3f675bf2c878ddcaf012fde7848b255826b
This commit is contained in:
Elliott Hughes 2012-09-04 15:42:23 -07:00
parent 1db615b4ae
commit 63deae5e4f

View File

@ -4049,13 +4049,21 @@ static void* sys_alloc(mstate m, size_t nb) {
} }
asize = granularity_align(nb + SYS_ALLOC_PADDING); 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 */ return 0; /* wraparound */
}
if (m->footprint_limit != 0) { if (m->footprint_limit != 0) {
size_t fp = m->footprint + asize; 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; return 0;
} }
}
/* /*
Try getting memory in any of three ways (in most-preferred to Try getting memory in any of three ways (in most-preferred to