[PATCH] D158293: [NFC][Clang] Fix static code analyzer concern about null value dereference

Soumi Manna via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 22 07:22:45 PDT 2023


Manna updated this revision to Diff 552347.
Manna retitled this revision from "[NFC][CLANG] Fix potential dereferencing of null return values" to "[NFC][Clang] Fix static code analyzer concern about null value dereference".
Manna added a comment.
Herald added subscribers: manas, ASDenysPetrov, dkrupp, donat.nagy, Szelethus, a.sidorin, baloghadamsoftware.

CurLexer is dereferenced and should not be null in clang::​Preprocessor::​SkipExcludedConditionalBlock(clang::​SourceLocation, clang::​SourceLocation, bool, bool, clang::​SourceLocation)

This patch adds  NULL value check for pointer CurLexer.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158293/new/

https://reviews.llvm.org/D158293

Files:
  clang/lib/Lex/PPDirectives.cpp


Index: clang/lib/Lex/PPDirectives.cpp
===================================================================
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -547,7 +547,7 @@
   } SkippingRangeState(*this);
 
   while (true) {
-    if (CurLexer->isDependencyDirectivesLexer()) {
+    if (CurLexer && CurLexer->isDependencyDirectivesLexer()) {
       CurLexer->LexDependencyDirectiveTokenWhileSkipping(Tok);
     } else {
       SkippingRangeState.beginLexPass();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158293.552347.patch
Type: text/x-patch
Size: 484 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230822/d45a2c97/attachment.bin>


More information about the cfe-commits mailing list