summaryrefslogtreecommitdiff
path: root/lib/Support/SmallPtrSet.cpp
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2007-07-19 06:45:33 +0000
committerOwen Anderson <resistor@mac.com>2007-07-19 06:45:33 +0000
commit71a1e57d1887341dc3093c12c464f1bc839e7ab5 (patch)
tree77b393e502caef773c84cf24892993dcbee7f07c /lib/Support/SmallPtrSet.cpp
parent19bc4a8acd0173fe76ac48b97c0bca20aa425b2b (diff)
downloadllvm-71a1e57d1887341dc3093c12c464f1bc839e7ab5.tar.gz
llvm-71a1e57d1887341dc3093c12c464f1bc839e7ab5.tar.bz2
llvm-71a1e57d1887341dc3093c12c464f1bc839e7ab5.tar.xz
Remember to free the heap allocated array if we're not going to use it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40043 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/SmallPtrSet.cpp')
-rw-r--r--lib/Support/SmallPtrSet.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/Support/SmallPtrSet.cpp b/lib/Support/SmallPtrSet.cpp
index b2c5c42e27..122a71da92 100644
--- a/lib/Support/SmallPtrSet.cpp
+++ b/lib/Support/SmallPtrSet.cpp
@@ -186,10 +186,12 @@ void SmallPtrSetImpl::CopyFrom(const SmallPtrSetImpl &RHS) {
"Cannot assign sets with different small sizes");
// If we're becoming small, prepare to insert into our stack space
- if (RHS.isSmall())
+ if (RHS.isSmall()) {
+ if (!isSmall())
+ free(CurArray);
CurArray = &SmallArray[0];
// Otherwise, allocate new heap space (unless we were the same size)
- else if (CurArraySize != RHS.CurArraySize) {
+ } else if (CurArraySize != RHS.CurArraySize) {
if (isSmall())
CurArray = (void**)malloc(sizeof(void*) * (RHS.CurArraySize+1));
else