diff options
author | Christopher Ferris <cferris@google.com> | 2014-06-09 19:14:11 -0700 |
---|---|---|
committer | Christopher Ferris <cferris@google.com> | 2014-06-12 15:08:18 -0700 |
commit | a403780538ac9d1a260e064df6599663f8cc4166 (patch) | |
tree | 340dd81279be34b49622c68dc037ceb5cd73bcc9 /libc/upstream-dlmalloc/malloc.c | |
parent | 0ada9388e74693d990bdbb4af92c33bae8b34d4b (diff) | |
download | bionic-a403780538ac9d1a260e064df6599663f8cc4166.zip bionic-a403780538ac9d1a260e064df6599663f8cc4166.tar.gz bionic-a403780538ac9d1a260e064df6599663f8cc4166.tar.bz2 |
Put all allocation functions into dispatch table.
Implement these new functions for all of the debug malloc types.
Fix a number of bugs in the debug malloc functions related to overflow
conditions.
Fix a bug in dlpvalloc due to an overflow condition.
Fix various other bugs in the debug malloc functions.
Add new tests for malloc functions.
Bug: 11225066
Change-Id: Idf50f389603e2157645565bc15cd9365eec2e9dd
Diffstat (limited to 'libc/upstream-dlmalloc/malloc.c')
-rw-r--r-- | libc/upstream-dlmalloc/malloc.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/libc/upstream-dlmalloc/malloc.c b/libc/upstream-dlmalloc/malloc.c index 3ef9b61..4362f49 100644 --- a/libc/upstream-dlmalloc/malloc.c +++ b/libc/upstream-dlmalloc/malloc.c @@ -5317,12 +5317,19 @@ void* dlvalloc(size_t bytes) { return dlmemalign(pagesz, bytes); } +/* BEGIN android-changed: added overflow check */ void* dlpvalloc(size_t bytes) { size_t pagesz; + size_t size; ensure_initialization(); pagesz = mparams.page_size; - return dlmemalign(pagesz, (bytes + pagesz - SIZE_T_ONE) & ~(pagesz - SIZE_T_ONE)); + size = (bytes + pagesz - SIZE_T_ONE) & ~(pagesz - SIZE_T_ONE); + if (size < bytes) { + return NULL; + } + return dlmemalign(pagesz, size); } +/* END android-change */ void** dlindependent_calloc(size_t n_elements, size_t elem_size, void* chunks[]) { |