From 044eb2f6afba375a914ac9d8024f8f5142bb912e Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Mon, 18 Dec 2017 20:10:56 +0000 Subject: Vendor import of llvm trunk r321017: https://llvm.org/svn/llvm-project/llvm/trunk@321017 --- lib/Support/SmallVector.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib/Support/SmallVector.cpp') diff --git a/lib/Support/SmallVector.cpp b/lib/Support/SmallVector.cpp index b931505bd6a1..74313151c762 100644 --- a/lib/Support/SmallVector.cpp +++ b/lib/Support/SmallVector.cpp @@ -26,14 +26,17 @@ void SmallVectorBase::grow_pod(void *FirstEl, size_t MinSizeInBytes, void *NewElts; if (BeginX == FirstEl) { NewElts = malloc(NewCapacityInBytes); + if (NewElts == nullptr) + report_bad_alloc_error("Allocation of SmallVector element failed."); // Copy the elements over. No need to run dtors on PODs. memcpy(NewElts, this->BeginX, CurSizeBytes); } else { // If this wasn't grown from the inline copy, grow the allocated space. NewElts = realloc(this->BeginX, NewCapacityInBytes); + if (NewElts == nullptr) + report_bad_alloc_error("Reallocation of SmallVector element failed."); } - assert(NewElts && "Out of memory"); this->EndX = (char*)NewElts+CurSizeBytes; this->BeginX = NewElts; -- cgit v1.2.3