[PATCH] D158295: [NFC][clang][analyzer] Avoid potential dereferencing of null pointer value

Soumi Manna via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 18 10:34:15 PDT 2023


Manna created this revision.
Manna added reviewers: aaron.ballman, tahonermann, steakhal.
Herald added subscribers: manas, ASDenysPetrov, martong, dkrupp, donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun.
Herald added a reviewer: NoQ.
Herald added a project: All.
Manna requested review of this revision.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158295

Files:
  clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp


Index: clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
===================================================================
--- clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
@@ -1425,7 +1425,10 @@
 
       // Fetch the new reference count from the state, and use it to handle
       // this symbol.
-      state = handleSymbolDeath(state, Sym, *getRefBinding(state, Sym), Leaked);
+      const RefVal* T = getRefBinding(state, Sym);
+      if (!T)
+        return;
+      state = handleSymbolDeath(state, Sym, *T, Leaked);
     }
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158295.551565.patch
Type: text/x-patch
Size: 674 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230818/060a1697/attachment.bin>


More information about the cfe-commits mailing list