summaryrefslogtreecommitdiffstats
path: root/clang/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
commite2bdb9a6e22764ac45649b7f3af09789aa08998d (patch)
tree7208868df4604a553f5daaa187a213275b97595d /clang/lib/Analysis/MallocChecker.cpp
parent7430a9861948ecbfe531034e71f7e077b40015e4 (diff)
downloadbcm5719-llvm-e2bdb9a6e22764ac45649b7f3af09789aa08998d.tar.gz
bcm5719-llvm-e2bdb9a6e22764ac45649b7f3af09789aa08998d.zip
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. llvm-svn: 93706
Diffstat (limited to 'clang/lib/Analysis/MallocChecker.cpp')
-rw-r--r--clang/lib/Analysis/MallocChecker.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/clang/lib/Analysis/MallocChecker.cpp b/clang/lib/Analysis/MallocChecker.cpp
index fab73ee7b10..5bd27912e41 100644
--- a/clang/lib/Analysis/MallocChecker.cpp
+++ b/clang/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()) {
OpenPOWER on IntegriCloud