@@ -1799,6 +1799,11 @@ resolve_func_type(const uint8 **p_buf, const uint8 *buf_end, WASMModule *module,
1799
1799
return false;
1800
1800
}
1801
1801
if (ref_type_map_count > 0) {
1802
+ if (ref_type_map_count > UINT16_MAX) {
1803
+ set_error_buf(error_buf, error_buf_size,
1804
+ "ref type count too large");
1805
+ return false;
1806
+ }
1802
1807
total_size = sizeof(WASMRefTypeMap) * (uint64)ref_type_map_count;
1803
1808
if (!(type->ref_type_maps =
1804
1809
loader_malloc(total_size, error_buf, error_buf_size))) {
@@ -1938,6 +1943,11 @@ resolve_struct_type(const uint8 **p_buf, const uint8 *buf_end,
1938
1943
return false;
1939
1944
}
1940
1945
if (ref_type_map_count > 0) {
1946
+ if (ref_type_map_count > UINT16_MAX) {
1947
+ set_error_buf(error_buf, error_buf_size,
1948
+ "ref type count too large");
1949
+ return false;
1950
+ }
1941
1951
total_size = sizeof(WASMRefTypeMap) * (uint64)ref_type_map_count;
1942
1952
if (!(type->ref_type_maps =
1943
1953
loader_malloc(total_size, error_buf, error_buf_size))) {
@@ -3957,6 +3967,11 @@ load_function_section(const uint8 *buf, const uint8 *buf_end,
3957
3967
}
3958
3968
#if WASM_ENABLE_GC != 0
3959
3969
if (ref_type_map_count > 0) {
3970
+ if (ref_type_map_count > UINT16_MAX) {
3971
+ set_error_buf(error_buf, error_buf_size,
3972
+ "ref type count too large");
3973
+ return false;
3974
+ }
3960
3975
total_size =
3961
3976
sizeof(WASMRefTypeMap) * (uint64)ref_type_map_count;
3962
3977
if (!(func->local_ref_type_maps = loader_malloc(
0 commit comments