From f0f4452ed488bc7d9c3b9693dc110f1107921a08 Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Sat, 12 Feb 2022 11:17:02 +0000 Subject: [PATCH] [clang][sema] Sema::CheckFreeArguments - use cast<> instead of dyn_cast<> to avoid dereference of nullptr The pointer is referenced immediately, so assert the cast is correct instead of returning nullptr --- clang/lib/Sema/SemaChecking.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 575181a6b61c..c422981a1a2e 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -11310,7 +11310,7 @@ void CheckFreeArgumentsCast(Sema &S, const std::string &CalleeName, /// Alerts the user that they are attempting to free a non-malloc'd object. void Sema::CheckFreeArguments(const CallExpr *E) { const std::string CalleeName = - dyn_cast(E->getCalleeDecl())->getQualifiedNameAsString(); + cast(E->getCalleeDecl())->getQualifiedNameAsString(); { // Prefer something that doesn't involve a cast to make things simpler. const Expr *Arg = E->getArg(0)->IgnoreParenCasts();