Index: src/wasm/wasm-module-builder.cc |
diff --git a/src/wasm/wasm-module-builder.cc b/src/wasm/wasm-module-builder.cc |
index b1b859ba42cbd9c0d63b2c0950869760a7f8b42b..5184b3dd8f573507d173a3b9f648355b8119eefe 100644 |
--- a/src/wasm/wasm-module-builder.cc |
+++ b/src/wasm/wasm-module-builder.cc |
@@ -190,7 +190,12 @@ void WasmFunctionBuilder::StashCode(std::vector<byte>* dst, size_t position) { |
body_.resize(position); |
return; |
} |
+ DCHECK_LE(position, body_.size()); |
size_t len = body_.size() - position; |
+ if (len == 0) { |
+ // Early out here as body_[position] is out of bounds in this case. |
Clemens Hammacher
2017/03/28 09:52:02
dst->resize(0) is not needed here?
You can avoid
bradnelson
2017/03/28 15:30:50
Ah good point.
Done.
|
+ return; |
+ } |
dst->resize(len); |
memcpy(dst->data(), &body_[position], len); |
body_.resize(position); |