summaryrefslogtreecommitdiff
path: root/cmdline
diff options
context:
space:
mode:
author Florian Mayer <fmayer@google.com> 2022-03-28 18:55:39 +0000
committer Florian Mayer <fmayer@google.com> 2022-03-29 16:04:28 +0000
commit838f6c4137663d1578bcf56b6b5f10b5dc42e258 (patch)
treef1cff19302114fbc4abde9bef9408ef5ec706088 /cmdline
parent26e70d86005d2f907edef5a4703d87aecbd42d57 (diff)
Fix use-after-scope in dex2oat cmdline parsing
Bug: 227217805 Change-Id: Ibf2f5e4892fc3199ec44a09721d4cbb921901732
Diffstat (limited to 'cmdline')
-rw-r--r--cmdline/detail/cmdline_parse_argument_detail.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/cmdline/detail/cmdline_parse_argument_detail.h b/cmdline/detail/cmdline_parse_argument_detail.h
index 95883cce38..0bde57bbae 100644
--- a/cmdline/detail/cmdline_parse_argument_detail.h
+++ b/cmdline/detail/cmdline_parse_argument_detail.h
@@ -150,9 +150,11 @@ struct CmdlineParserArgumentInfo {
for (auto cname : names_) {
std::string_view name = cname;
auto& os = vios.Stream();
+ // nblank gets captured by print_once, so needs to be declared here.
+ std::string_view nblank;
std::function<void()> print_once;
if (using_blanks_) {
- std::string_view nblank = name.substr(0, name.find("_"));
+ nblank = name.substr(0, name.find("_"));
print_once = [&]() {
os << nblank;
if (has_value_map_) {