summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer
diff options
context:
space:
mode:
authorArtem Dergachev <artem.dergachev@gmail.com>2018-03-21 00:57:37 +0000
committerArtem Dergachev <artem.dergachev@gmail.com>2018-03-21 00:57:37 +0000
commit69949d0b5a44be358367298367d44ebda20e7bff (patch)
treebad9c2f5bc5bb15039052ec7f1bd6b9aebbe6782 /clang/lib/StaticAnalyzer
parentff1fc21e8a6974d2e3469bf37362bf61a408fced (diff)
downloadbcm5719-llvm-69949d0b5a44be358367298367d44ebda20e7bff.tar.gz
bcm5719-llvm-69949d0b5a44be358367298367d44ebda20e7bff.zip
Revert r326782 "[analyzer] CStringChecker.cpp: Remove the duplicated check...".
It seems that the refactoring was causing a functional change and some warnings have disappeared. llvm-svn: 328067
Diffstat (limited to 'clang/lib/StaticAnalyzer')
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
index 4eb189e2281..bd4033784ef 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -1033,6 +1033,21 @@ void CStringChecker::evalCopyCommon(CheckerContext &C,
if (stateNonZeroSize) {
state = stateNonZeroSize;
+ // Ensure the destination is not null. If it is NULL there will be a
+ // NULL pointer dereference.
+ state = checkNonNull(C, state, Dest, destVal);
+ if (!state)
+ return;
+
+ // Get the value of the Src.
+ SVal srcVal = state->getSVal(Source, LCtx);
+
+ // Ensure the source is not null. If it is NULL there will be a
+ // NULL pointer dereference.
+ state = checkNonNull(C, state, Source, srcVal);
+ if (!state)
+ return;
+
// Ensure the accesses are valid and that the buffers do not overlap.
const char * const writeWarning =
"Memory copy function overflows destination buffer";
@@ -2018,6 +2033,12 @@ void CStringChecker::evalMemset(CheckerContext &C, const CallExpr *CE) const {
return;
}
+ // Ensure the memory area is not null.
+ // If it is NULL there will be a NULL pointer dereference.
+ State = checkNonNull(C, StateNonZeroSize, Mem, MemVal);
+ if (!State)
+ return;
+
State = CheckBufferAccess(C, State, Size, Mem);
if (!State)
return;
OpenPOWER on IntegriCloud