mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-05-09 21:26:21 +00:00
loader: Sub local count can be 0 (#1504)
Sub local count is allowed to be 0 in each group of function local types.
This commit is contained in:
parent
046f5f2212
commit
64c0b15c52
|
@ -1950,8 +1950,8 @@ load_function_section(const uint8 *buf, const uint8 *buf_end,
|
||||||
local_type_index = 0;
|
local_type_index = 0;
|
||||||
for (j = 0; j < local_set_count; j++) {
|
for (j = 0; j < local_set_count; j++) {
|
||||||
read_leb_uint32(p_code, buf_code_end, sub_local_count);
|
read_leb_uint32(p_code, buf_code_end, sub_local_count);
|
||||||
if (!sub_local_count
|
/* Note: sub_local_count is allowed to be 0 */
|
||||||
|| local_type_index > UINT32_MAX - sub_local_count
|
if (local_type_index > UINT32_MAX - sub_local_count
|
||||||
|| local_type_index + sub_local_count > local_count) {
|
|| local_type_index + sub_local_count > local_count) {
|
||||||
set_error_buf(error_buf, error_buf_size,
|
set_error_buf(error_buf, error_buf_size,
|
||||||
"invalid local count");
|
"invalid local count");
|
||||||
|
|
|
@ -1013,8 +1013,8 @@ load_function_section(const uint8 *buf, const uint8 *buf_end,
|
||||||
local_type_index = 0;
|
local_type_index = 0;
|
||||||
for (j = 0; j < local_set_count; j++) {
|
for (j = 0; j < local_set_count; j++) {
|
||||||
read_leb_uint32(p_code, buf_code_end, sub_local_count);
|
read_leb_uint32(p_code, buf_code_end, sub_local_count);
|
||||||
bh_assert(sub_local_count
|
/* Note: sub_local_count is allowed to be 0 */
|
||||||
&& local_type_index <= UINT32_MAX - sub_local_count
|
bh_assert(local_type_index <= UINT32_MAX - sub_local_count
|
||||||
&& local_type_index + sub_local_count <= local_count);
|
&& local_type_index + sub_local_count <= local_count);
|
||||||
|
|
||||||
CHECK_BUF(p_code, buf_code_end, 1);
|
CHECK_BUF(p_code, buf_code_end, 1);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user