diff options
author | Jason Evans <je@fb.com> | 2015-01-17 02:04:17 (GMT) |
---|---|---|
committer | Jason Evans <je@fb.com> | 2015-01-17 02:04:17 (GMT) |
commit | 44b57b8e8b25797b94c7cccc0e32705f76fcf03b (patch) | |
tree | 0688def7584e902b56f97fc1b9a7fdde2a901893 /src | |
parent | 24057f3da8cd1b23955068a368165eba2eefb5c4 (diff) | |
download | jemalloc-44b57b8e8b25797b94c7cccc0e32705f76fcf03b.zip jemalloc-44b57b8e8b25797b94c7cccc0e32705f76fcf03b.tar.gz jemalloc-44b57b8e8b25797b94c7cccc0e32705f76fcf03b.tar.bz2 |
Fix OOM handling in memalign() and valloc().
Fix memalign() and valloc() to heed imemalign()'s return value.
Reported by Kurt Wampler.
Diffstat (limited to 'src')
-rw-r--r-- | src/jemalloc.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/jemalloc.c b/src/jemalloc.c index e63dab3..aecdce3 100644 --- a/src/jemalloc.c +++ b/src/jemalloc.c @@ -1751,7 +1751,8 @@ void * je_memalign(size_t alignment, size_t size) { void *ret JEMALLOC_CC_SILENCE_INIT(NULL); - imemalign(&ret, alignment, size, 1); + if (unlikely(imemalign(&ret, alignment, size, 1) != 0)) + ret = NULL; JEMALLOC_VALGRIND_MALLOC(ret != NULL, ret, size, false); return (ret); } @@ -1762,7 +1763,8 @@ void * je_valloc(size_t size) { void *ret JEMALLOC_CC_SILENCE_INIT(NULL); - imemalign(&ret, PAGE, size, 1); + if (unlikely(imemalign(&ret, PAGE, size, 1) != 0)) + ret = NULL; JEMALLOC_VALGRIND_MALLOC(ret != NULL, ret, size, false); return (ret); } |