[llvm-branch-commits] [flang] 3e41ab1 - [flang] Fix dangling pointer in LabelEnforce
Tim Keith via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Jan 14 06:57:37 PST 2021
Author: Tim Keith
Date: 2021-01-14T06:52:21-08:00
New Revision: 3e41ab18db2255028c288a11665c08d260654299
URL: https://github.com/llvm/llvm-project/commit/3e41ab18db2255028c288a11665c08d260654299
DIFF: https://github.com/llvm/llvm-project/commit/3e41ab18db2255028c288a11665c08d260654299.diff
LOG: [flang] Fix dangling pointer in LabelEnforce
`DirectiveStructureChecker` was passing in a pointer to a temporary
string for the `construct` argument to the constructor for `LabelEnforce`.
The `LabelEnforce` object had a lifetime longer than the temporary,
resulting in accessing a dangling pointer when emitting an error message
for `omp-parallell01.f90`.
The fix is to make the lifetime of the temporary as long as the lifetime
of the `LabelEnforce` object.
Differential Revision: https://reviews.llvm.org/D94618
Added:
Modified:
flang/lib/Semantics/check-directive-structure.h
Removed:
################################################################################
diff --git a/flang/lib/Semantics/check-directive-structure.h b/flang/lib/Semantics/check-directive-structure.h
index 1075087feb4f..76157ac93925 100644
--- a/flang/lib/Semantics/check-directive-structure.h
+++ b/flang/lib/Semantics/check-directive-structure.h
@@ -280,9 +280,9 @@ void DirectiveStructureChecker<D, C, PC, ClauseEnumSize>::CheckNoBranching(
context_, directiveSource, directive, ContextDirectiveAsFortran()};
parser::Walk(block, noBranchingEnforce);
+ auto construct{parser::ToUpperCaseLetters(getDirectiveName(directive).str())};
LabelEnforce directiveLabelEnforce{context_, noBranchingEnforce.labels(),
- directiveSource,
- parser::ToUpperCaseLetters(getDirectiveName(directive).str()).c_str()};
+ directiveSource, construct.c_str()};
parser::Walk(block, directiveLabelEnforce);
}
More information about the llvm-branch-commits
mailing list