summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
author Vladimir Marko <vmarko@google.com> 2015-09-04 11:10:40 +0100
committer Vladimir Marko <vmarko@google.com> 2015-09-04 11:10:40 +0100
commit305ff2d5481f7f53147d92f5e632949542803ecd (patch)
tree3387af62c8c4ad867a6bc213e177b1110a0f8471 /compiler
parent68ffda887e35f35e978f2f607b7a91e44a5e1969 (diff)
ART: Abort if malloc() fails in SwapAllocator::allocate().
Change-Id: I084da8d376b0a86fc551b87d77ce9c74e60359bf
Diffstat (limited to 'compiler')
-rw-r--r--compiler/utils/swap_space.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/compiler/utils/swap_space.h b/compiler/utils/swap_space.h
index f7c772d673..9127b6b096 100644
--- a/compiler/utils/swap_space.h
+++ b/compiler/utils/swap_space.h
@@ -163,7 +163,9 @@ class SwapAllocator {
pointer allocate(size_type n, SwapAllocator<void>::pointer hint ATTRIBUTE_UNUSED = nullptr) {
DCHECK_LE(n, max_size());
if (swap_space_ == nullptr) {
- return reinterpret_cast<T*>(malloc(n * sizeof(T)));
+ T* result = reinterpret_cast<T*>(malloc(n * sizeof(T)));
+ CHECK(result != nullptr || n == 0u); // Abort if malloc() fails.
+ return result;
} else {
return reinterpret_cast<T*>(swap_space_->Alloc(n * sizeof(T)));
}