aboutsummaryrefslogtreecommitdiff
path: root/clang
diff options
context:
space:
mode:
authorsmanna12 <soumi.manna@intel.com>2024-07-01 11:03:03 -0700
committerGitHub <noreply@github.com>2024-07-01 13:03:03 -0500
commit1c0e7221ce35e4b709951c06c67aeb1ed3205f27 (patch)
treec1e6e734e39b0041a467500f3ce320084aa363af /clang
parenta5e905b73d4aec4365a63040338cb02118ae80e5 (diff)
downloadllvm-1c0e7221ce35e4b709951c06c67aeb1ed3205f27.zip
llvm-1c0e7221ce35e4b709951c06c67aeb1ed3205f27.tar.gz
llvm-1c0e7221ce35e4b709951c06c67aeb1ed3205f27.tar.bz2
[Clang] Prevent null pointer dereference in DiagnoseDeclAvailability() (#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.
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Sema/SemaAvailability.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaAvailability.cpp b/clang/lib/Sema/SemaAvailability.cpp
index fed1c68..df83bbf 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();