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

Unified Diff: tools/gn/parser.cc

Issue 1275853006: Fix some crashes in GN. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/parser.cc
diff --git a/tools/gn/parser.cc b/tools/gn/parser.cc
index 286409b5ed48a6d3b207a37c37ddfe306af313fb..b2e22fb09f63a2f383fd7ee2bcf73896ea570fc2 100644
--- a/tools/gn/parser.cc
+++ b/tools/gn/parser.cc
@@ -374,6 +374,11 @@ scoped_ptr<ParseNode> Parser::Not(Token token) {
scoped_ptr<ParseNode> expr = ParseExpression(PRECEDENCE_PREFIX + 1);
if (has_error())
return scoped_ptr<ParseNode>();
+ if (!expr) {
+ if (!has_error())
+ *err_ = Err(token, "Expected right-hand side for '!'.");
+ return scoped_ptr<ParseNode>();
+ }
scoped_ptr<UnaryOpNode> unary_op(new UnaryOpNode);
unary_op->set_op(token);
unary_op->set_operand(expr.Pass());
@@ -393,7 +398,7 @@ scoped_ptr<ParseNode> Parser::BinaryOperator(scoped_ptr<ParseNode> left,
ParseExpression(expressions_[token.type()].precedence + 1);
if (!right) {
if (!has_error()) {
- *err_ = Err(token, "Expected right hand side for '" +
+ *err_ = Err(token, "Expected right-hand side for '" +
token.value().as_string() + "'");
}
return scoped_ptr<ParseNode>();
@@ -451,6 +456,11 @@ scoped_ptr<ParseNode> Parser::Assignment(scoped_ptr<ParseNode> left,
return scoped_ptr<ParseNode>();
}
scoped_ptr<ParseNode> value = ParseExpression(PRECEDENCE_ASSIGNMENT);
+ if (!value) {
+ if (!has_error())
+ *err_ = Err(token, "Expected right-hand side for assignment.");
+ return scoped_ptr<ParseNode>();
+ }
scoped_ptr<BinaryOpNode> assign(new BinaryOpNode);
assign->set_op(token);
assign->set_left(left.Pass());
« no previous file with comments | « no previous file | tools/gn/parser_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698