summaryrefslogtreecommitdiff
path: root/src/wasm-binary-reader.c
diff options
context:
space:
mode:
authorBen Smith <binji@chromium.org>2016-04-25 07:11:01 -0700
committerBen Smith <binji@chromium.org>2016-04-28 23:45:51 -0700
commit8ff085d37bb107cabe7e9305553f7c3179e4ded8 (patch)
tree2e8f8f1ec78689fb1594ca509a3bd0fb75c205e0 /src/wasm-binary-reader.c
parent8b8647dc8f4cc032d5ce932fd4df22ff3714086d (diff)
downloadwabt-8ff085d37bb107cabe7e9305553f7c3179e4ded8.tar.gz
wabt-8ff085d37bb107cabe7e9305553f7c3179e4ded8.tar.bz2
wabt-8ff085d37bb107cabe7e9305553f7c3179e4ded8.zip
move section length after section name
Diffstat (limited to 'src/wasm-binary-reader.c')
-rw-r--r--src/wasm-binary-reader.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/wasm-binary-reader.c b/src/wasm-binary-reader.c
index e95edb0c..160eeb1d 100644
--- a/src/wasm-binary-reader.c
+++ b/src/wasm-binary-reader.c
@@ -328,15 +328,13 @@ static WasmBool skip_until_section(WasmContext* ctx, int section_index) {
return WASM_FALSE;
}
+ WasmStringSlice section_name;
+ in_str(ctx, &section_name, "section name");
in_u32_leb128(ctx, &section_size, "section size");
- uint32_t after_size_offset = ctx->offset;
- if (after_size_offset + section_size > ctx->size)
+ if (ctx->offset + section_size > ctx->size)
RAISE_ERROR(ctx, "invalid section size: extends past end");
- WasmStringSlice section_name;
- in_str(ctx, &section_name, "section name");
-
int index = -1;
#define V(name) \
else if (strncmp(section_name.start, WASM_SECTION_NAME_##name, \
@@ -350,7 +348,7 @@ static WasmBool skip_until_section(WasmContext* ctx, int section_index) {
if (index == -1) {
/* ok, unknown section, skip it. */
- ctx->offset = after_size_offset + section_size;
+ ctx->offset += section_size;
return 0;
} else if (index < section_index) {
RAISE_ERROR(ctx, "section " PRIstringslice " out of order",