[clang] 8a75faf - [NFC][CLANG] Fix null pointer dereferences (#86760)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 27 15:13:01 PDT 2024
Author: smanna12
Date: 2024-03-27T17:12:58-05:00
New Revision: 8a75faf4717b8258b59cf9fbb4cbd2f189114d3f
URL: https://github.com/llvm/llvm-project/commit/8a75faf4717b8258b59cf9fbb4cbd2f189114d3f
DIFF: https://github.com/llvm/llvm-project/commit/8a75faf4717b8258b59cf9fbb4cbd2f189114d3f.diff
LOG: [NFC][CLANG] Fix null pointer dereferences (#86760)
This patch replaces getAs<> with castAs<> to resolve potential static
analyzer bugs for
1. Dereferencing Proto1->param_type_begin(), which is known to be
nullptr
2. Dereferencing Proto2->param_type_begin(), which is known to be
nullptr
3. Dereferencing a pointer issue with nullptr Proto1 when calling
param_type_end()
4. Dereferencing a pointer issue with nullptr Proto2 when calling
param_type_end()
in clang::Sema::getMoreSpecializedTemplate().
Added:
Modified:
clang/lib/Sema/SemaTemplateDeduction.cpp
Removed:
################################################################################
diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp b/clang/lib/Sema/SemaTemplateDeduction.cpp
index 97f8445bf819c8..9a55881f644254 100644
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -5514,9 +5514,9 @@ FunctionTemplateDecl *Sema::getMoreSpecializedTemplate(
QualType Obj2Ty;
if (TPOC == TPOC_Call) {
const FunctionProtoType *Proto1 =
- FD1->getType()->getAs<FunctionProtoType>();
+ FD1->getType()->castAs<FunctionProtoType>();
const FunctionProtoType *Proto2 =
- FD2->getType()->getAs<FunctionProtoType>();
+ FD2->getType()->castAs<FunctionProtoType>();
// - In the context of a function call, the function parameter types are
// used.
More information about the cfe-commits
mailing list