Chromium Code Reviews| Index: src/wasm/module-decoder.cc |
| diff --git a/src/wasm/module-decoder.cc b/src/wasm/module-decoder.cc |
| index 62b000da2bfd8b3d5df0b2c612a027ffe0a64946..a4600a470f9383e3d93e0625aabcd4e1e611e8b6 100644 |
| --- a/src/wasm/module-decoder.cc |
| +++ b/src/wasm/module-decoder.cc |
| @@ -55,6 +55,7 @@ class ModuleDecoder : public Decoder { |
| module->data_segments = new std::vector<WasmDataSegment>(); |
| module->function_table = new std::vector<uint16_t>(); |
| module->import_table = new std::vector<WasmImport>(); |
| + module->export_table = new std::vector<WasmExport>(); |
| bool sections[kMaxModuleSectionCode]; |
| memset(sections, 0, sizeof(sections)); |
| @@ -234,6 +235,31 @@ class ModuleDecoder : public Decoder { |
| } |
| break; |
| } |
| + case kDeclExportTable: { |
| + // Declares an export table. |
| + CheckForPreviousSection(sections, kDeclFunctions, true); |
| + int length; |
| + uint32_t export_table_count = |
| + consume_u32v(&length, "export table count"); |
| + module->export_table->reserve(SafeReserve(export_table_count)); |
| + // Decode export table. |
| + for (uint32_t i = 0; i < export_table_count; i++) { |
| + if (failed()) break; |
| + TRACE("DecodeExportTable[%d] module+%d\n", i, |
| + static_cast<int>(pc_ - start_)); |
| + |
| + module->export_table->push_back({0, 0}); |
|
JF
2016/02/27 00:59:48
What happens if SafeReserve clamped the reserved s
|
| + WasmExport* exp = &module->export_table->back(); |
| + |
| + const byte* sigpos = pc_; |
| + exp->func_index = consume_u16("function index"); |
| + if (exp->func_index >= module->functions->size()) { |
| + error(sigpos, "invalid function index"); |
|
JF
2016/02/27 00:59:48
error(sigpos, "invalid function index %i, max is %
|
| + } |
| + exp->name_offset = consume_string("export name"); |
| + } |
| + break; |
| + } |
| case kDeclWLL: { |
| // Reserved for experimentation by the Web Low-level Language project |
| // which is augmenting the binary encoding with source code meta |