Skip to content

Commit

Permalink
[Clang][NFC] Fix potential null dereference in encodeTypeForFunctionP…
Browse files Browse the repository at this point in the history
…ointerAuth (llvm#104737)

This patch replaces getAs with castAs in
encodeTypeForFunctionPointerAuth to prevent dereferencing a potential
null pointer, enhancing type safety as reported by static analyzer tool.
  • Loading branch information
smanna12 authored Aug 19, 2024
1 parent 4f083c0 commit 79f6ae0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion clang/lib/AST/ASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3279,7 +3279,7 @@ static void encodeTypeForFunctionPointerAuth(const ASTContext &Ctx,

case Type::MemberPointer: {
OS << "M";
const auto *MPT = T->getAs<MemberPointerType>();
const auto *MPT = T->castAs<MemberPointerType>();
encodeTypeForFunctionPointerAuth(Ctx, OS, QualType(MPT->getClass(), 0));
encodeTypeForFunctionPointerAuth(Ctx, OS, MPT->getPointeeType());
return;
Expand Down

0 comments on commit 79f6ae0

Please sign in to comment.