diff options
author | Tim Keith <tkeith@nvidia.com> | 2021-01-14 06:52:18 -0800 |
---|---|---|
committer | Tim Keith <tkeith@nvidia.com> | 2021-01-14 06:52:21 -0800 |
commit | 3e41ab18db2255028c288a11665c08d260654299 (patch) | |
tree | 83bc668b03af2dd76a3c0614be22b9ee7345b044 /flang | |
parent | 0b46f19a9ecd6215cffb51d19f2403c18b0226f5 (diff) | |
download | llvm-3e41ab18db2255028c288a11665c08d260654299.zip llvm-3e41ab18db2255028c288a11665c08d260654299.tar.gz llvm-3e41ab18db2255028c288a11665c08d260654299.tar.bz2 |
[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
Diffstat (limited to 'flang')
-rw-r--r-- | flang/lib/Semantics/check-directive-structure.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/flang/lib/Semantics/check-directive-structure.h b/flang/lib/Semantics/check-directive-structure.h index 1075087..76157ac 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); } |