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

Unified Diff: src/wasm/decoder.h

Issue 1743773002: WebAssembly: skip unknown sections, add names (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: git cl format Created 4 years, 10 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 | src/wasm/module-decoder.cc » ('j') | src/wasm/module-decoder.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « no previous file | src/wasm/module-decoder.cc » ('j') | src/wasm/module-decoder.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698