LibWeb/WebAssembly: Throw when a table type's max > initial

This commit is contained in:
Diego Frias 2024-08-17 17:14:37 -07:00 committed by Ali Mohammad Pur
parent 80434fa516
commit 0aa76b5f67
Notes: github-actions[bot] 2024-08-18 21:35:59 +00:00

View file

@ -38,6 +38,9 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Table>> Table::construct_impl(JS::Realm& re
? Detail::default_webassembly_value(vm, reference_type)
: TRY(Detail::to_webassembly_value(vm, value, reference_type));
if (descriptor.maximum.has_value() && descriptor.maximum.value() < descriptor.initial)
return vm.throw_completion<JS::RangeError>("Maximum should not be less than initial in table type"sv);
Wasm::Limits limits { descriptor.initial, move(descriptor.maximum) };
Wasm::TableType table_type { reference_type, move(limits) };