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

Unified Diff: src/parsing/scanner.cc

Issue 2258073003: Fix Scanner invariants w/ literal buffers. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
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 | « src/parsing/scanner.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/scanner.cc
diff --git a/src/parsing/scanner.cc b/src/parsing/scanner.cc
index f9438ca11da40ace4cca7b22bee8e96c90da6df8..06ead2e827a4975369988448fdff459c17856aff 100644
--- a/src/parsing/scanner.cc
+++ b/src/parsing/scanner.cc
@@ -1598,14 +1598,9 @@ void Scanner::ResetToBookmark() {
source_->ResetToBookmark();
c0_ = bookmark_c0_;
- StartLiteral();
- StartRawLiteral();
- CopyTokenDesc(&next_, &bookmark_current_);
+ CopyToNextTokenDesc(&bookmark_current_);
current_ = next_;
- StartLiteral();
- StartRawLiteral();
- CopyTokenDesc(&next_, &bookmark_next_);
-
+ CopyToNextTokenDesc(&bookmark_next_);
bookmark_c0_ = kBookmarkWasApplied;
}
@@ -1620,6 +1615,13 @@ bool Scanner::BookmarkHasBeenReset() {
void Scanner::DropBookmark() { bookmark_c0_ = kNoBookmark; }
+void Scanner::CopyToNextTokenDesc(TokenDesc* from) {
+ StartLiteral();
+ StartRawLiteral();
+ CopyTokenDesc(&next_, from);
+ if (next_.literal_chars->length() == 0) next_.literal_chars = nullptr;
+ if (next_.raw_literal_chars->length() == 0) next_.raw_literal_chars = nullptr;
+}
void Scanner::CopyTokenDesc(TokenDesc* to, TokenDesc* from) {
DCHECK_NOT_NULL(to);
« no previous file with comments | « src/parsing/scanner.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698