summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/include/llvm/Support/Allocator.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/llvm/include/llvm/Support/Allocator.h b/llvm/include/llvm/Support/Allocator.h
index a94aa8fb1f2..7f9c39345b4 100644
--- a/llvm/include/llvm/Support/Allocator.h
+++ b/llvm/include/llvm/Support/Allocator.h
@@ -24,6 +24,7 @@
#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/MathExtras.h"
+#include "llvm/Support/ErrorHandling.h"
#include <algorithm>
#include <cassert>
#include <cstddef>
@@ -94,7 +95,11 @@ public:
LLVM_ATTRIBUTE_RETURNS_NONNULL void *Allocate(size_t Size,
size_t /*Alignment*/) {
- return malloc(Size);
+ void* memPtr = malloc(Size);
+ if (memPtr == nullptr)
+ report_bad_alloc_error("Allocation in MallocAllocator failed.");
+
+ return memPtr;
}
// Pull in base class overloads.
OpenPOWER on IntegriCloud