[PATCH] D31868: [analyzer] Check NULL pointer dereference issue for memset function
Daniel Marjamäki via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 12 04:27:47 PDT 2017
danielmarjamaki added a comment.
Thanks! Looks like a valueable addition.
================
Comment at: lib/StaticAnalyzer/Checkers/CStringChecker.cpp:2004
+void CStringChecker::evalMemset(CheckerContext &C, const CallExpr *CE) const {
+ if (CE->getNumArgs() < 3)
+ return;
----------------
even better: != 3
================
Comment at: lib/StaticAnalyzer/Checkers/CStringChecker.cpp:2009
+
+ const Expr *S = CE->getArg(0);
+ const Expr *Size = CE->getArg(2);
----------------
The name "S" does not tell me much.. how about something like Data / DataArg / PtrArg / ..?
================
Comment at: lib/StaticAnalyzer/Checkers/CStringChecker.cpp:2011
+ const Expr *Size = CE->getArg(2);
+ ProgramStateRef state = C.getState();
+
----------------
Variables should start with capital.. State, SizeVal, SizeTy, ...
================
Comment at: lib/StaticAnalyzer/Checkers/CStringChecker.cpp:2034
+ // If the size can be nonzero, we have to check the other arguments.
+ if (stateNonZeroSize) {
+ state = stateNonZeroSize;
----------------
use early return:
if (!stateNonZeroSize)
return;
Repository:
rL LLVM
https://reviews.llvm.org/D31868
More information about the cfe-commits
mailing list