summaryrefslogtreecommitdiff
path: root/src/wasm-binary-reader.c
diff options
context:
space:
mode:
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",