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"); |