summaryrefslogtreecommitdiff
path: root/libcxxabi/src/cxa_demangle.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libcxxabi/src/cxa_demangle.cpp')
-rw-r--r--libcxxabi/src/cxa_demangle.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/libcxxabi/src/cxa_demangle.cpp b/libcxxabi/src/cxa_demangle.cpp
index 78d667117fd..9a2c83a9bec 100644
--- a/libcxxabi/src/cxa_demangle.cpp
+++ b/libcxxabi/src/cxa_demangle.cpp
@@ -1771,13 +1771,17 @@ class BumpPointerAllocator {
BlockMeta* BlockList = nullptr;
void grow() {
- char* NewMeta = new char[AllocSize];
+ char* NewMeta = static_cast<char *>(std::malloc(AllocSize));
+ if (NewMeta == nullptr)
+ std::terminate();
BlockList = new (NewMeta) BlockMeta{BlockList, 0};
}
void* allocateMassive(size_t NBytes) {
NBytes += sizeof(BlockMeta);
- BlockMeta* NewMeta = reinterpret_cast<BlockMeta*>(new char[NBytes]);
+ BlockMeta* NewMeta = reinterpret_cast<BlockMeta*>(std::malloc(NBytes));
+ if (NewMeta == nullptr)
+ std::terminate();
BlockList->Next = new (NewMeta) BlockMeta{BlockList->Next, 0};
return static_cast<void*>(NewMeta + 1);
}
@@ -1803,7 +1807,7 @@ public:
BlockMeta* Tmp = BlockList;
BlockList = BlockList->Next;
if (reinterpret_cast<char*>(Tmp) != InitialBuffer)
- delete[] reinterpret_cast<char*>(Tmp);
+ std::free(Tmp);
}
BlockList = new (InitialBuffer) BlockMeta{nullptr, 0};
}
@@ -1833,10 +1837,15 @@ class PODSmallVector {
size_t S = size();
if (isInline()) {
auto* Tmp = static_cast<T*>(std::malloc(NewCap * sizeof(T)));
+ if (Tmp == nullptr)
+ std::terminate();
std::copy(First, Last, Tmp);
First = Tmp;
- } else
+ } else {
First = static_cast<T*>(std::realloc(First, NewCap * sizeof(T)));
+ if (First == nullptr)
+ std::terminate();
+ }
Last = First + S;
Cap = First + NewCap;
}