[flang-commits] [flang] 6da1f22 - [Flang] Fix usage of uninitialized resolution variable
Paul Scoropan via flang-commits
flang-commits at lists.llvm.org
Wed Apr 5 08:01:02 PDT 2023
Author: Paul Scoropan
Date: 2023-04-05T15:00:56Z
New Revision: 6da1f2277dd1fbd560204c6ab0e129eb3cb0906b
URL: https://github.com/llvm/llvm-project/commit/6da1f2277dd1fbd560204c6ab0e129eb3cb0906b
DIFF: https://github.com/llvm/llvm-project/commit/6da1f2277dd1fbd560204c6ab0e129eb3cb0906b.diff
LOG: [Flang] Fix usage of uninitialized resolution variable
Recent Flang PowerPC intrinsics patch used resolution variable without checking if it exists first, causing segmentation faults in some scenarios. This patch checks that the resolution variable exists first before usage.
Reviewed By: DanielCChen
Differential Revision: https://reviews.llvm.org/D147616
Added:
Modified:
flang/lib/Semantics/expression.cpp
Removed:
################################################################################
diff --git a/flang/lib/Semantics/expression.cpp b/flang/lib/Semantics/expression.cpp
index 06226f282c1cd..cec936c8f5e42 100644
--- a/flang/lib/Semantics/expression.cpp
+++ b/flang/lib/Semantics/expression.cpp
@@ -2518,12 +2518,12 @@ auto ExpressionAnalyzer::GetCalleeAndArguments(const parser::Name &name,
mightBeStructureConstructor)};
resolution = pair.first;
dueToAmbiguity = pair.second;
- if (context_.GetPPCBuiltinsScope() &&
- resolution->name().ToString().rfind("__ppc_", 0) == 0) {
- semantics::CheckPPCIntrinsic(
- *symbol, *resolution, arguments, GetFoldingContext());
- }
if (resolution) {
+ if (context_.GetPPCBuiltinsScope() &&
+ resolution->name().ToString().rfind("__ppc_", 0) == 0) {
+ semantics::CheckPPCIntrinsic(
+ *symbol, *resolution, arguments, GetFoldingContext());
+ }
// re-resolve name to the specific procedure
name.symbol = const_cast<Symbol *>(resolution);
}
More information about the flang-commits
mailing list