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

Unified Diff: src/wasm/module-decoder.cc

Issue 2362663002: [wasm] Break loops in the module-decoder upon error. (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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/wasm/module-decoder.cc
diff --git a/src/wasm/module-decoder.cc b/src/wasm/module-decoder.cc
index 0aa620722949803b3e733159b5ea10d50a24cea9..7a602110f90b9bfb674e330e12eeec7e92e219e5 100644
--- a/src/wasm/module-decoder.cc
+++ b/src/wasm/module-decoder.cc
@@ -187,6 +187,7 @@ class ModuleDecoder : public Decoder {
break;
}
for (uint32_t i = 0; i < functions_count; ++i) {
+ if (failed()) break;
titzer 2016/09/22 09:53:11 Can we change all these loops to be for(x, ok() &&
ahaas 2016/09/22 12:35:09 Done.
WasmFunction* function = &module->functions[i];
uint32_t size = consume_u32v("body size");
function->code_start_offset = pc_offset();
@@ -212,12 +213,14 @@ class ModuleDecoder : public Decoder {
}
for (uint32_t i = 0; i < functions_count; ++i) {
+ if (failed()) break;
WasmFunction* function = &module->functions[i];
function->name_offset =
consume_string(&function->name_length, false);
uint32_t local_names_count = consume_u32v("local names count");
for (uint32_t j = 0; j < local_names_count; j++) {
+ if (failed()) break;
uint32_t unused = 0;
uint32_t offset = consume_string(&unused, false);
USE(unused);
@@ -519,6 +522,7 @@ class ModuleDecoder : public Decoder {
}
for (uint32_t i = 0; i < table->size; ++i) {
+ if (failed()) break;
uint16_t index = consume_u32v();
if (index >= module->functions.size()) {
error(pc_ - sizeof(index), "invalid function index");
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698