diff options
-rw-r--r-- | src/wasm-binary.h | 2 | ||||
-rw-r--r-- | src/wasm/wasm-binary.cpp | 19 |
2 files changed, 13 insertions, 8 deletions
diff --git a/src/wasm-binary.h b/src/wasm-binary.h index 6ec55f757..1edd3fa12 100644 --- a/src/wasm-binary.h +++ b/src/wasm-binary.h @@ -638,7 +638,7 @@ public: WasmBinaryBuilder(Module& wasm, std::vector<char>& input, bool debug) : wasm(wasm), allocator(wasm.allocator), input(input), debug(debug) {} void read(); - bool readUserSection(); + void readUserSection(); bool more() { return pos < input.size();} uint8_t getInt8(); diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index 4a4c878e9..66f744e17 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -890,6 +890,8 @@ void WasmBinaryBuilder::read() { uint32_t payloadLen = getU32LEB(); if (pos + payloadLen > input.size()) throw ParseException("Section extends beyond end of input"); + auto oldPos = pos; + switch (sectionCode) { case BinaryConsts::Section::Start: readStart(); break; case BinaryConsts::Section::Memory: readMemory(); break; @@ -909,23 +911,26 @@ void WasmBinaryBuilder::read() { } case BinaryConsts::Section::Data: readDataSegments(); break; case BinaryConsts::Section::Table: readFunctionTableDeclaration(); break; - - default: - if (!readUserSection()) abort(); + default: { + readUserSection(); + pos = oldPos + payloadLen; + } } + + // make sure we advanced exactly past this section + assert(pos == oldPos + payloadLen); } processFunctions(); } -bool WasmBinaryBuilder::readUserSection() { +void WasmBinaryBuilder::readUserSection() { Name sectionName = getInlineString(); if (sectionName.equals(BinaryConsts::UserSections::Name)) { readNames(); - return true; + } else { + std::cerr << "unfamiliar section: " << sectionName << std::endl; } - std::cerr << "unfamiliar section: " << sectionName << std::endl; - return false; } uint8_t WasmBinaryBuilder::getInt8() { |