Skip to content

Commit

Permalink
[NFC][CLANG] Fix null pointer dereferences (#86760)
Browse files Browse the repository at this point in the history
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().
  • Loading branch information
smanna12 committed Mar 27, 2024
1 parent d5f0634 commit 8a75faf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions clang/lib/Sema/SemaTemplateDeduction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 8a75faf

Please sign in to comment.