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

Unified Diff: src/scanner-character-streams.cc

Issue 1156103015: Fix free-after-free bug in ExternalStreamingStream::ResetToBookmark. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/scanner-character-streams.cc
diff --git a/src/scanner-character-streams.cc b/src/scanner-character-streams.cc
index 40d2abcf13f79e08c33e75e58445184248c6a696..bc5cde490685d8ba1a2719acab56a33bb0f60fab 100644
--- a/src/scanner-character-streams.cc
+++ b/src/scanner-character-streams.cc
@@ -434,10 +434,14 @@ void ExternalStreamingStream::ResetToBookmark() {
pos_ = bookmark_;
- // current_data_ can point to bookmark_data_'s buffer.
- current_data_ = bookmark_data_.start();
+ // bookmark_data_* => current_data_*
+ // (current_data_ assumes ownership of its memory.)
+ uint8_t* data = new uint8_t[bookmark_data_.length()];
current_data_offset_ = 0;
current_data_length_ = bookmark_data_.length();
+ CopyCharsUnsigned(data, bookmark_data_.begin(), bookmark_data_.length());
+ delete[] current_data_;
+ current_data_ = data;
// bookmark_buffer_ needs to be copied to buffer_.
CopyCharsUnsigned(buffer_, bookmark_buffer_.begin(),
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698