Skip to content

Commit

Permalink
Fixing a possible memory leak from a failing realloc() call.
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195018 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
AaronBallman committed Nov 18, 2013
1 parent 6919bec commit eae6e54
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/Support/SmallPtrSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,13 @@ void SmallPtrSetImpl::CopyFrom(const SmallPtrSetImpl &RHS) {
} else if (CurArraySize != RHS.CurArraySize) {
if (isSmall())
CurArray = (const void**)malloc(sizeof(void*) * RHS.CurArraySize);
else
CurArray = (const void**)realloc(CurArray, sizeof(void*)*RHS.CurArraySize);
else {
const void **T = (const void**)realloc(CurArray,
sizeof(void*) * RHS.CurArraySize);
if (!T)
free(CurArray);
CurArray = T;
}
assert(CurArray && "Failed to allocate memory?");
}

Expand Down

0 comments on commit eae6e54

Please sign in to comment.