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_; } |