Wasm loader enhancement: check code size in code entry (#3892)

add wasm loader check: in code entry, the code size should match the size of vec(locals) + expr, and expr should end with opcode end
This commit is contained in:
TianlongLiang
2024-11-07 13:38:42 +08:00
committed by GitHub
parent e352f0ab10
commit bf78863c56
2 changed files with 19 additions and 9 deletions

View File

@ -1183,6 +1183,8 @@ load_function_section(const uint8 *buf, const uint8 *buf_end,
local_count += sub_local_count;
}
bh_assert(p_code_end > p_code && *(p_code_end - 1) == WASM_OP_END);
/* Alloc memory, layout: function structure + local types */
code_size = (uint32)(p_code_end - p_code);