Author: Ryosuke Niwa
Date: 2026-01-28T09:05:44-08:00
New Revision: 68695090ccf1fc7d1b6245d3f6efc18cabd7633b

URL: 
https://github.com/llvm/llvm-project/commit/68695090ccf1fc7d1b6245d3f6efc18cabd7633b
DIFF: 
https://github.com/llvm/llvm-project/commit/68695090ccf1fc7d1b6245d3f6efc18cabd7633b.diff

LOG: [alpha.webkit.NoDeleteChecker] Fix a nullptr deference crash during 
lookupInBases (#178351)

Added a null check in the lambda passed to lookupInBases.

Added: 
    

Modified: 
    clang/lib/StaticAnalyzer/Checkers/WebKit/NoDeleteChecker.cpp
    clang/test/Analysis/Checkers/WebKit/nodelete-annotation.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/NoDeleteChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/NoDeleteChecker.cpp
index 397fda8cd67ed..1edb435919b41 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/NoDeleteChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/NoDeleteChecker.cpp
@@ -82,6 +82,9 @@ class NoDeleteChecker : public 
Checker<check::ASTDecl<TranslationUnitDecl>> {
                 return false;
 
               const CXXRecordDecl *R = T->getAsCXXRecordDecl();
+              if (!R)
+                return false;
+
               for (const CXXMethodDecl *BaseMD : R->methods()) {
                 if (BaseMD->getCorrespondingMethodInClass(Cls) == MD) {
                   if (isNoDeleteFunction(FD)) {

diff  --git a/clang/test/Analysis/Checkers/WebKit/nodelete-annotation.cpp 
b/clang/test/Analysis/Checkers/WebKit/nodelete-annotation.cpp
index b23fd007ff789..fc4108e855b66 100644
--- a/clang/test/Analysis/Checkers/WebKit/nodelete-annotation.cpp
+++ b/clang/test/Analysis/Checkers/WebKit/nodelete-annotation.cpp
@@ -65,3 +65,15 @@ class DerivedClass : public IntermediateClass {
     someFunction();
   }
 };
+
+template <class Type>
+class Base {
+public:
+  virtual unsigned foo() const = 0;
+};
+
+template <class Type>
+class Derived : public Base<Type> {
+public:
+  virtual unsigned foo() const { return 0; }
+};


        
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to