summaryrefslogtreecommitdiffstats
path: root/libc/upstream-dlmalloc
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2012-09-04 15:42:23 -0700
committerElliott Hughes <enh@google.com>2012-09-04 15:42:23 -0700
commit63deae5e4f186a453fb6fbab0d8acf314aab4df0 (patch)
tree60c9e9358eca95ca7151760087289643c4068c5f /libc/upstream-dlmalloc
parent1db615b4ae469c9f33dc1d88b24924ca8efc10ef (diff)
downloadbionic-63deae5e4f186a453fb6fbab0d8acf314aab4df0.zip
bionic-63deae5e4f186a453fb6fbab0d8acf314aab4df0.tar.gz
bionic-63deae5e4f186a453fb6fbab0d8acf314aab4df0.tar.bz2
Add missing MALLOC_FAILURE_ACTION calls to dlmalloc.
Without these, sometimes malloc(3) returns NULL without setting errno. Change-Id: I4708c3f675bf2c878ddcaf012fde7848b255826b
Diffstat (limited to 'libc/upstream-dlmalloc')
-rw-r--r--libc/upstream-dlmalloc/malloc.c12
1 files changed, 10 insertions, 2 deletions
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 @@ 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;
+ }
}
/*