[clang] [NFC] Avoid potential null deref by adding an assert. (PR #127017)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 13 00:05:52 PST 2025
https://github.com/schittir updated https://github.com/llvm/llvm-project/pull/127017
>From 66a9f9938ead51155560c911537c00bad7c644df Mon Sep 17 00:00:00 2001
From: Sindhu Chittireddy <sindhu.chittireddy at intel.com>
Date: Wed, 12 Feb 2025 23:27:01 -0800
Subject: [PATCH 1/2] [NFC] Avoid potential null deref by adding an assert.
---
clang/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp | 1 +
1 file changed, 1 insertion(+)
diff --git a/clang/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp
index 12bf12a0b2322..8955cb209c399 100644
--- a/clang/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp
@@ -314,6 +314,7 @@ void MacOSKeychainAPIChecker::checkPreStmt(const CallExpr *CE,
RegionArgIsBad = true;
}
+ assert(ArgSM);
// Is the argument to the call being tracked?
const AllocationState *AS = State->get<AllocatedData>(ArgSM);
if (!AS)
>From 0149532e4e47e5f3f0b09efb1392659719591957 Mon Sep 17 00:00:00 2001
From: Sindhu Chittireddy <sindhu.chittireddy at intel.com>
Date: Thu, 13 Feb 2025 00:04:28 -0800
Subject: [PATCH 2/2] Avoid potential null deref of OASE
---
clang/lib/CodeGen/CGOpenMPRuntime.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index b679d63874b3b..9f7db25a15bec 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -7447,7 +7447,7 @@ class MappableExprsHandler {
// Update info about the lowest and highest elements for this struct
if (!PartialStruct.Base.isValid()) {
PartialStruct.LowestElem = {FieldIndex, LowestElem};
- if (IsFinalArraySection) {
+ if (IsFinalArraySection && OASE) {
Address HB =
CGF.EmitArraySectionExpr(OASE, /*IsLowerBound=*/false)
.getAddress();
@@ -7460,7 +7460,7 @@ class MappableExprsHandler {
} else if (FieldIndex < PartialStruct.LowestElem.first) {
PartialStruct.LowestElem = {FieldIndex, LowestElem};
} else if (FieldIndex > PartialStruct.HighestElem.first) {
- if (IsFinalArraySection) {
+ if (IsFinalArraySection && OASE) {
Address HB =
CGF.EmitArraySectionExpr(OASE, /*IsLowerBound=*/false)
.getAddress();
More information about the cfe-commits
mailing list