gn: fix fuzzer bug in parser for stack local
ParseNode::GetRange() returns a LocationRange by value, so the reference taken
is invalid at the next ;. Copy the Location by value instead.
R=brettw@chromium.org
BUG=683454
Review-Url: https://codereview.chromium.org/2654143005
Cr-Original-Commit-Position: refs/heads/master@{#446528}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 0fcc08c5d93f2e8128d5e583c236dd2a81e70a7b
diff --git a/tools/gn/parser.cc b/tools/gn/parser.cc
index 447dfcf..7e2c7f4 100644
--- a/tools/gn/parser.cc
+++ b/tools/gn/parser.cc
@@ -824,7 +824,7 @@
CHECK_EQ(node, file) << "Only expected on top file node";
continue;
}
- const Location& start = node->GetRange().begin();
+ const Location start = node->GetRange().begin();
while (cur_comment < static_cast<int>(line_comment_tokens_.size())) {
if (start.byte() >= line_comment_tokens_[cur_comment].location().byte()) {
const_cast<ParseNode*>(node)->comments_mutable()->append_before(