https://github.com/smanna12 created https://github.com/llvm/llvm-project/pull/94368
…erToDecl This patch adds null check for 'Init' before dereferencing it to prevent potential null pointer dereferences reported by static Analyzer tool in the function. >From b6d45ded3d0d1ad6a50a1292d4f8275081089150 Mon Sep 17 00:00:00 2001 From: "Manna, Soumi" <soumi.ma...@intel.com> Date: Tue, 4 Jun 2024 08:33:51 -0700 Subject: [PATCH] [Clang] Fix potential null pointer dereferences in Sema::AddInitializerToDecl This patch adds null check for 'Init' before dereferencing it to prevent potential null pointer dereferences reported by static Analyzer tool in the function. --- clang/lib/Sema/SemaDecl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 34e46e12859bb..cd50df646b8b2 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -13728,7 +13728,7 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, bool DirectInit) { // paths through the function. This should be revisited if // -Wrepeated-use-of-weak is made flow-sensitive. if (FunctionScopeInfo *FSI = getCurFunction()) - if ((VDecl->getType().getObjCLifetime() == Qualifiers::OCL_Strong || + if (Init && (VDecl->getType().getObjCLifetime() == Qualifiers::OCL_Strong || VDecl->getType().isNonWeakInMRRWithObjCWeak(Context)) && !Diags.isIgnored(diag::warn_arc_repeated_use_of_weak, Init->getBeginLoc())) _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits