mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
LibWeb: Throw range error when initial is greater than maximum
When constructing WebAssembly.Memory if initial is greater than maximum a range error will be thrown. Fixes "Initial value exceeds maximum" in https://wpt.fyi/results/wasm/jsapi/memory/constructor.any.worker.html?product=ladybird
This commit is contained in:
committed by
Ali Mohammad Pur
parent
6d3fd2b543
commit
62fe795c9b
Notes:
github-actions[bot]
2025-09-10 03:24:12 +00:00
Author: https://github.com/me-it-is 🔰 Commit: https://github.com/LadybirdBrowser/ladybird/commit/62fe795c9b7 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6122 Reviewed-by: https://github.com/alimpfard Reviewed-by: https://github.com/gmta
@@ -23,6 +23,11 @@ WebIDL::ExceptionOr<GC::Ref<Memory>> Memory::construct_impl(JS::Realm& realm, Me
|
||||
auto& vm = realm.vm();
|
||||
|
||||
// https://webassembly.github.io/threads/js-api/index.html#dom-memory-memory
|
||||
// 3. If maximum is not empty and maximum < initial, throw a RangeError exception.
|
||||
if (descriptor.maximum.has_value() && descriptor.maximum.value() < descriptor.initial) {
|
||||
return vm.throw_completion<JS::RangeError>("Initial is larger than maximum."sv);
|
||||
}
|
||||
|
||||
// 4. Let share be shared if descriptor["shared"] is true and unshared otherwise.
|
||||
// 5. If share is shared and maximum is empty, throw a TypeError exception.
|
||||
auto shared = descriptor.shared.value_or(false);
|
||||
|
||||
Reference in New Issue
Block a user