https://github.com/smanna12 created 
https://github.com/llvm/llvm-project/pull/97095

This patch adds an assertion in the DiagnoseDeclAvailabilit() function to 
ensure that the expected availability attribute is not null before they are 
passed to hasMatchingEnvironmentOrNone() to prevent potential null pointer 
dereferences and improve the robustness of the availability diagnostics process.

>From 2f67313eca49d27c4a20b33215a81d4ad80ba7e3 Mon Sep 17 00:00:00 2001
From: "Manna, Soumi" <soumi.ma...@intel.com>
Date: Fri, 28 Jun 2024 11:29:52 -0700
Subject: [PATCH] [Clang] Prevent null pointer dereference in
 DiagnoseDeclAvailability()

This patch adds an assertion in the DiagnoseDeclAvailabilit() function to 
ensure that the expected availability attribute is not null before they are 
passed to hasMatchingEnvironmentOrNone() to prevent potential null pointer 
dereferences and improve the robustness of the availability diagnostics process.
---
 clang/lib/Sema/SemaAvailability.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/clang/lib/Sema/SemaAvailability.cpp 
b/clang/lib/Sema/SemaAvailability.cpp
index fed1c68d4d33a..df83bbfb7aac8 100644
--- a/clang/lib/Sema/SemaAvailability.cpp
+++ b/clang/lib/Sema/SemaAvailability.cpp
@@ -842,6 +842,7 @@ void 
DiagnoseUnguardedAvailability::DiagnoseDeclAvailability(
 
     const AvailabilityAttr *AA =
       getAttrForPlatform(SemaRef.getASTContext(), OffendingDecl);
+    assert(AA != nullptr && "expecting valid availability attribute");
     bool EnvironmentMatchesOrNone =
         hasMatchingEnvironmentOrNone(SemaRef.getASTContext(), AA);
     VersionTuple Introduced = AA->getIntroduced();

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to