Revert "[esnext] fix OOB read in ASTPrinter::VisistTemplateLiteral"

This reverts commit 0802e2b262.

Reason for revert: For reverting https://crrev.com/c/945408

Original change's description:
> [esnext] fix OOB read in ASTPrinter::VisistTemplateLiteral
> 
> Fixes an error where TemplateLiteral printing in --print-ast
> would try to read an element beyond the length of a vector.
> 
> BUG=v8:7415, chromium:820596
> R=​adamk@chromium.org, gsathya@chromium.org
> 
> Change-Id: Idf9e0da8c165ee62bc1a348a91c2ed5ed798404a
> Reviewed-on: https://chromium-review.googlesource.com/957883
> Reviewed-by: Adam Klein <adamk@chromium.org>
> Commit-Queue: Caitlin Potter <caitp@igalia.com>
> Cr-Commit-Position: refs/heads/master@{#51857}

TBR=adamk@chromium.org,gsathya@chromium.org,caitp@igalia.com

Change-Id: I5fe950cd823ae350b5f6c09227a62aef9dc2a008
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: v8:7415, chromium:820596
Reviewed-on: https://chromium-review.googlesource.com/957724
Reviewed-by: Michael Achenbach <machenbach@chromium.org>
Commit-Queue: Michael Achenbach <machenbach@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51861}
This commit is contained in:
Michael Achenbach 2018-03-10 16:44:11 +00:00 committed by Commit Bot
parent 4cb681e7d1
commit 89204e90bb
2 changed files with 3 additions and 13 deletions

View File

@ -1356,12 +1356,10 @@ void AstPrinter::VisitTemplateLiteral(TemplateLiteral* node) {
IndentedScope indent(this, "TEMPLATE-LITERAL", node->position());
const AstRawString* string = node->string_parts()->first();
if (!string->IsEmpty()) PrintLiteralIndented("SPAN", string, true);
for (int i = 0; i < node->substitutions()->length();) {
for (int i = 0; i < node->string_parts()->length();) {
PrintIndentedVisit("EXPR", node->substitutions()->at(i++));
if (i < node->string_parts()->length()) {
string = node->string_parts()->at(i);
if (!string->IsEmpty()) PrintLiteralIndented("SPAN", string, true);
}
string = node->string_parts()->at(i);
if (!string->IsEmpty()) PrintLiteralIndented("SPAN", string, true);
}
}

View File

@ -1,8 +0,0 @@
// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --print-ast
var x;
`Crashes if OOB read with --print-ast ${x}`;