[cfe-commits] r96154 - in /cfe/trunk: lib/Checker/MallocChecker.cpp test/Analysis/malloc.c
Zhongxing Xu
xuzhongxing at gmail.com
Sat Feb 13 22:49:48 PST 2010
Author: zhongxingxu
Date: Sun Feb 14 00:49:48 2010
New Revision: 96154
URL: http://llvm.org/viewvc/llvm-project?rev=96154&view=rev
Log:
Fix pr6293. If ptr is NULL, no operation is preformed.
Modified:
cfe/trunk/lib/Checker/MallocChecker.cpp
cfe/trunk/test/Analysis/malloc.c
Modified: cfe/trunk/lib/Checker/MallocChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/MallocChecker.cpp?rev=96154&r1=96153&r2=96154&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/MallocChecker.cpp (original)
+++ cfe/trunk/lib/Checker/MallocChecker.cpp Sun Feb 14 00:49:48 2010
@@ -172,6 +172,11 @@
const GRState *MallocChecker::FreeMemAux(CheckerContext &C, const CallExpr *CE,
const GRState *state) {
SVal ArgVal = state->getSVal(CE->getArg(0));
+
+ // If ptr is NULL, no operation is preformed.
+ if (ArgVal.isZeroConstant())
+ return state;
+
SymbolRef Sym = ArgVal.getAsLocSymbol();
assert(Sym);
Modified: cfe/trunk/test/Analysis/malloc.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/malloc.c?rev=96154&r1=96153&r2=96154&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/malloc.c (original)
+++ cfe/trunk/test/Analysis/malloc.c Sun Feb 14 00:49:48 2010
@@ -57,3 +57,7 @@
char *buf = doit2();
free(buf);
}
+
+void pr6293() {
+ free(0);
+}
More information about the cfe-commits
mailing list