summaryrefslogtreecommitdiff
path: root/src/wasm/wasm-binary.cpp
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2016-12-07 14:30:52 -1000
committerGitHub <noreply@github.com>2016-12-07 14:30:52 -1000
commit6c4f6d7022ebdd640f2a8e4df8c4885774b9b184 (patch)
tree0f32dc0c06e3465df77d1a8b58e12df37a8548e4 /src/wasm/wasm-binary.cpp
parent76ddda73d630d50839c2eef5e86a96e16625b6ed (diff)
downloadbinaryen-6c4f6d7022ebdd640f2a8e4df8c4885774b9b184.tar.gz
binaryen-6c4f6d7022ebdd640f2a8e4df8c4885774b9b184.tar.bz2
binaryen-6c4f6d7022ebdd640f2a8e4df8c4885774b9b184.zip
ignore unknown user sections, fixes #857 (#858)
Diffstat (limited to 'src/wasm/wasm-binary.cpp')
-rw-r--r--src/wasm/wasm-binary.cpp19
1 files changed, 12 insertions, 7 deletions
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() {