From: Henry Wong Date: Tue, 6 Mar 2018 13:38:42 +0000 (+0000) Subject: [analyzer] CStringChecker.cpp: Remove the duplicated check about null dereference... X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=945a84a03ca30c2a610e878dc2199591b3422d87;p=platform%2Fupstream%2Fllvm.git [analyzer] CStringChecker.cpp: Remove the duplicated check about null dereference on dest-buffer or src-buffer. Summary: `CheckBufferAccess()` calls `CheckNonNull()`, so there are some calls to `CheckNonNull()` that are useless. Reviewers: dcoughlin, NoQ, xazax.hun, cfe-commits, george.karpenkov Reviewed By: NoQ Subscribers: szepet, rnkovacs, MTC, a.sidorin Differential Revision: https://reviews.llvm.org/D44075 llvm-svn: 326782 --- diff --git a/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp index bd40337..4eb189e 100644 --- a/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp @@ -1033,21 +1033,6 @@ 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"; @@ -2033,12 +2018,6 @@ 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;