| Index: src/wasm/decoder.h
|
| diff --git a/src/wasm/decoder.h b/src/wasm/decoder.h
|
| index 0e88eda022de439228b6f862098dff55376ae954..25d46b33f063e91af92381298a686819c8a28c03 100644
|
| --- a/src/wasm/decoder.h
|
| +++ b/src/wasm/decoder.h
|
| @@ -222,10 +222,19 @@ class Decoder {
|
| return traceOffEnd<uint32_t>();
|
| }
|
|
|
| + // Consume {size} bytes and send them to the bit bucket, advancing {pc_}.
|
| + void consume_bytes(size_t size) {
|
| + if (checkAvailable(size)) {
|
| + pc_ += size;
|
| + } else {
|
| + pc_ = limit_;
|
| + }
|
| + }
|
| +
|
| // Check that at least {size} bytes exist between {pc_} and {limit_}.
|
| - bool checkAvailable(int size) {
|
| - if (pc_ < start_ || (pc_ + size) > limit_) {
|
| - error(pc_, nullptr, "expected %d bytes, fell off end", size);
|
| + bool checkAvailable(size_t size) {
|
| + if (pc_ < start_ || (limit_ - start_) < size || limit_ < (pc_ + size)) {
|
| + error(pc_, nullptr, "expected %z bytes, fell off end", size);
|
| return false;
|
| } else {
|
| return true;
|
|
|