-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[clang][NFC] Avoid potential null dereferences #127017
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-clang-static-analyzer-1 @llvm/pr-subscribers-clang-codegen Author: None (schittir) ChangesAdd null checking. Full diff: https://github.com/llvm/llvm-project/pull/127017.diff 2 Files Affected:
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();
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)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Im good with the analyzer part, but im not familiar with the other.
That part is not obvious to me, so id suggest an additional reviewer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Add null checking.
Add null checking.
This assertion was hit, as reported by a user. llvm#128427 (comment) Ideally, we would reduce and add a regression test for this, but I don't have the bandwidth for it. See the summary of the issue llvm#128427 for the reproducer.
This assertion was hit, as reported by a user. #128427 (comment) Ideally, we would reduce and add a regression test for this, but I don't have the bandwidth for it. See the summary of the issue #128427 for the reproducer.
Add null checking.