r326782 - [analyzer] CStringChecker.cpp: Remove the duplicated check about null dereference on dest-buffer or src-buffer.

Henry Wong via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 6 05:38:42 PST 2018


Author: henrywong
Date: Tue Mar  6 05:38:42 2018
New Revision: 326782

URL: http://llvm.org/viewvc/llvm-project?rev=326782&view=rev
Log:
[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

Modified:
    cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp?rev=326782&r1=326781&r2=326782&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp Tue Mar  6 05:38:42 2018
@@ -1033,21 +1033,6 @@ void CStringChecker::evalCopyCommon(Chec
   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(CheckerC
     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;




More information about the cfe-commits mailing list