aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/MallocChecker.cpp
diff options
context:
space:
mode:
authorZhongxing Xu <xuzhongxing@gmail.com>2010-01-18 03:27:34 +0000
committerZhongxing Xu <xuzhongxing@gmail.com>2010-01-18 03:27:34 +0000
commit7e3cda9744204d19e0691bcb473cac1529b5fadd (patch)
treed68ca7b6ee4d8c1f05578bfca1c5ad6bdb00a128 /lib/Analysis/MallocChecker.cpp
parentd478cc7c1cd737c3033b96a883f619f0b1beaf24 (diff)
If the symbol has not been tracked, do not free it. This is possible when free
is called on a pointer that does not get its value directly from malloc. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93706 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/MallocChecker.cpp')
-rw-r--r--lib/Analysis/MallocChecker.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/Analysis/MallocChecker.cpp b/lib/Analysis/MallocChecker.cpp
index fab73ee7b1..5bd27912e4 100644
--- a/lib/Analysis/MallocChecker.cpp
+++ b/lib/Analysis/MallocChecker.cpp
@@ -170,7 +170,12 @@ const GRState *MallocChecker::FreeMemAux(CheckerContext &C, const CallExpr *CE,
assert(Sym);
const RefState *RS = state->get<RegionState>(Sym);
- assert(RS);
+
+ // If the symbol has not been tracked, return. This is possible when free() is
+ // called on a pointer that does not get its pointee directly from malloc().
+ // Full support of this requires inter-procedural analysis.
+ if (!RS)
+ return state;
// Check double free.
if (RS->isReleased()) {