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

Unified Diff: src/parsing/parser.cc

Issue 1575133003: [parser] fix null-dereference in DoExpression rewriting (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 11 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 | « src/parsing/parser.h ('k') | test/mjsunit/harmony/do-expressions.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/parser.cc
diff --git a/src/parsing/parser.cc b/src/parsing/parser.cc
index 0f80ec66f157880404dbf89691cc0075420c3050..27b1d4b81dd25c4663468a65fe0a665e8f8ac5b1 100644
--- a/src/parsing/parser.cc
+++ b/src/parsing/parser.cc
@@ -2196,7 +2196,8 @@ Statement* Parser::ParseClassDeclaration(ZoneList<const AstRawString*>* names,
}
-Block* Parser::ParseBlock(ZoneList<const AstRawString*>* labels, bool* ok) {
+Block* Parser::ParseBlock(ZoneList<const AstRawString*>* labels,
+ bool finalize_block_scope, bool* ok) {
// The harmony mode uses block elements instead of statements.
//
// Block ::
@@ -2222,12 +2223,19 @@ Block* Parser::ParseBlock(ZoneList<const AstRawString*>* labels, bool* ok) {
}
Expect(Token::RBRACE, CHECK_OK);
block_scope->set_end_position(scanner()->location().end_pos);
- block_scope = block_scope->FinalizeBlockScope();
+ if (finalize_block_scope) {
+ block_scope = block_scope->FinalizeBlockScope();
+ }
body->set_scope(block_scope);
return body;
}
+Block* Parser::ParseBlock(ZoneList<const AstRawString*>* labels, bool* ok) {
+ return ParseBlock(labels, true, ok);
+}
+
+
Block* Parser::DeclarationParsingResult::BuildInitializationBlock(
ZoneList<const AstRawString*>* names, bool* ok) {
Block* result = descriptor.parser->factory()->NewBlock(
@@ -3992,12 +4000,13 @@ DoExpression* Parser::ParseDoExpression(bool* ok) {
Expect(Token::DO, CHECK_OK);
Variable* result =
scope_->NewTemporary(ast_value_factory()->dot_result_string());
- Block* block = ParseBlock(nullptr, CHECK_OK);
+ Block* block = ParseBlock(nullptr, false, CHECK_OK);
DoExpression* expr = factory()->NewDoExpression(block, result, pos);
if (!Rewriter::Rewrite(this, expr, ast_value_factory())) {
*ok = false;
return nullptr;
}
+ block->set_scope(block->scope()->FinalizeBlockScope());
return expr;
}
« no previous file with comments | « src/parsing/parser.h ('k') | test/mjsunit/harmony/do-expressions.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698