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

Unified Diff: src/wasm/encoder.h

Issue 2355803002: [wasm] Fix EnsureSpace in the ZoneBuffer of the wasm encoder. (Closed)
Patch Set: Created 4 years, 3 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 | test/unittests/wasm/encoder-unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/wasm/encoder.h
diff --git a/src/wasm/encoder.h b/src/wasm/encoder.h
index 50ec6e5eaf61d32ec1141aa3dc342d8d519f5205..95fb885db6a200f28a407c8e9e5d54c06e60af02 100644
--- a/src/wasm/encoder.h
+++ b/src/wasm/encoder.h
@@ -90,13 +90,14 @@ class ZoneBuffer : public ZoneObject {
void EnsureSpace(size_t size) {
if ((pos_ + size) > end_) {
- size_t new_size = 4096 + (end_ - buffer_) * 3;
+ size_t new_size = 4096 + size + (end_ - buffer_) * 3;
byte* new_buffer = reinterpret_cast<byte*>(zone_->New(new_size));
memcpy(new_buffer, buffer_, (pos_ - buffer_));
pos_ = new_buffer + (pos_ - buffer_);
buffer_ = new_buffer;
end_ = new_buffer + new_size;
}
+ DCHECK(pos_ + size <= end_);
}
byte** pos_ptr() { return &pos_; }
« no previous file with comments | « no previous file | test/unittests/wasm/encoder-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698