diff options
author | Daniel Sanders <daniel.sanders@imgtec.com> | 2015-06-09 09:47:46 +0000 |
---|---|---|
committer | Daniel Sanders <daniel.sanders@imgtec.com> | 2015-06-09 09:47:46 +0000 |
commit | 0389d66b0cd5f1b2669e451f6513b0b34c94a9fa (patch) | |
tree | 10b0efc2dccf103e205d6a2884399cb665dc3c91 /llvm/lib | |
parent | c09e376d8e2e4748709d34afad25f13d8b632071 (diff) | |
download | bcm5719-llvm-0389d66b0cd5f1b2669e451f6513b0b34c94a9fa.tar.gz bcm5719-llvm-0389d66b0cd5f1b2669e451f6513b0b34c94a9fa.zip |
[ADT] Assert that SmallVectorBase::grow_pod() successfully reallocates memory.
Summary:
If malloc/realloc fails then the SmallVector becomes unusable since begin() and
end() will return NULL. This is unlikely to occur but was the cause of recent
bugpoint test failures on my machine.
It is not clear whether not checking for malloc/realloc failure is a deliberate
decision and adding checks has the potential to impact compiler performance.
Therefore, this patch only adds the check to builds with assertions enabled for
the moment.
Reviewers: bkramer
Reviewed By: bkramer
Subscribers: bkramer, llvm-commits
Differential Revision: http://reviews.llvm.org/D9520
llvm-svn: 239392
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Support/SmallVector.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/llvm/lib/Support/SmallVector.cpp b/llvm/lib/Support/SmallVector.cpp index f9c0e78270c..b931505bd6a 100644 --- a/llvm/lib/Support/SmallVector.cpp +++ b/llvm/lib/Support/SmallVector.cpp @@ -33,6 +33,7 @@ void SmallVectorBase::grow_pod(void *FirstEl, size_t MinSizeInBytes, // If this wasn't grown from the inline copy, grow the allocated space. NewElts = realloc(this->BeginX, NewCapacityInBytes); } + assert(NewElts && "Out of memory"); this->EndX = (char*)NewElts+CurSizeBytes; this->BeginX = NewElts; |