From c4b6d0ebab4cfa0942aed43f030f3d57179c112e Mon Sep 17 00:00:00 2001 From: Serge Pavlov Date: Wed, 30 May 2018 09:01:12 +0000 Subject: Revert commit 333506 It looks like this commit is responsible for the fail: http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-autoconf/builds/24382. llvm-svn: 333518 --- llvm/lib/Support/SmallPtrSet.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'llvm/lib/Support/SmallPtrSet.cpp') diff --git a/llvm/lib/Support/SmallPtrSet.cpp b/llvm/lib/Support/SmallPtrSet.cpp index fed4a17..119bb87 100644 --- a/llvm/lib/Support/SmallPtrSet.cpp +++ b/llvm/lib/Support/SmallPtrSet.cpp @@ -32,7 +32,9 @@ void SmallPtrSetImplBase::shrink_and_clear() { NumNonEmpty = NumTombstones = 0; // Install the new array. Clear all the buckets to empty. - CurArray = (const void**)safe_malloc(sizeof(void*) * CurArraySize); + CurArray = (const void**)malloc(sizeof(void*) * CurArraySize); + if (CurArray == nullptr) + report_bad_alloc_error("Allocation of SmallPtrSet bucket array failed."); memset(CurArray, -1, CurArraySize*sizeof(void*)); } @@ -98,7 +100,9 @@ void SmallPtrSetImplBase::Grow(unsigned NewSize) { bool WasSmall = isSmall(); // Install the new array. Clear all the buckets to empty. - const void **NewBuckets = (const void**) safe_malloc(sizeof(void*) * NewSize); + const void **NewBuckets = (const void**) malloc(sizeof(void*) * NewSize); + if (NewBuckets == nullptr) + report_bad_alloc_error("Allocation of SmallPtrSet bucket array failed."); // Reset member only if memory was allocated successfully CurArray = NewBuckets; @@ -128,7 +132,9 @@ SmallPtrSetImplBase::SmallPtrSetImplBase(const void **SmallStorage, CurArray = SmallArray; // Otherwise, allocate new heap space (unless we were the same size) } else { - CurArray = (const void**)safe_malloc(sizeof(void*) * that.CurArraySize); + CurArray = (const void**)malloc(sizeof(void*) * that.CurArraySize); + if (CurArray == nullptr) + report_bad_alloc_error("Allocation of SmallPtrSet bucket array failed."); } // Copy over the that array. @@ -157,12 +163,16 @@ void SmallPtrSetImplBase::CopyFrom(const SmallPtrSetImplBase &RHS) { // Otherwise, allocate new heap space (unless we were the same size) } else if (CurArraySize != RHS.CurArraySize) { if (isSmall()) - CurArray = (const void**)safe_malloc(sizeof(void*) * RHS.CurArraySize); + CurArray = (const void**)malloc(sizeof(void*) * RHS.CurArraySize); else { - const void **T = (const void**)safe_realloc(CurArray, + const void **T = (const void**)realloc(CurArray, sizeof(void*) * RHS.CurArraySize); + if (!T) + free(CurArray); CurArray = T; } + if (CurArray == nullptr) + report_bad_alloc_error("Allocation of SmallPtrSet bucket array failed."); } CopyHelper(RHS); -- cgit v1.1