Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Unified Diff: tools/gn/parser.h

Issue 2282493002: gn: Don't do an out-of-bound access if a file ends after 'else' (Closed)
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/gn/parser.cc » ('j') | tools/gn/parser.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/parser.h
diff --git a/tools/gn/parser.h b/tools/gn/parser.h
index 29580da2b4a2946341c760ba2b43e01ae7c2f4af..22acb472876b799becbf4d04ce51d150c5cbb65e 100644
--- a/tools/gn/parser.h
+++ b/tools/gn/parser.h
@@ -111,8 +111,13 @@ class Parser {
const char* error_message);
Token Consume();
+ // Call this only if !at_end().
const Token& cur_token() const { return tokens_[cur_]; }
+ const Token& cur_or_last_token() const {
+ return at_end() ? tokens_[tokens_.size() - 1] : cur_token();
+ }
+
bool done() const { return at_end() || has_error(); }
bool at_end() const { return cur_ >= tokens_.size(); }
bool has_error() const { return err_->has_error(); }
« no previous file with comments | « no previous file | tools/gn/parser.cc » ('j') | tools/gn/parser.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698