-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
LibWeb: Throw range error when initial is greater than maximum #6122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
LibWeb: Throw range error when initial is greater than maximum #6122
Conversation
when constructing WebAssembly.Memory if initial is greater than maximum a range error will be thrown. fixes https://wpt.fyi/results/wasm/jsapi/memory/constructor.any.worker.html?product=ladybird Initial value exceeds maximum
90378aa
to
5873129
Compare
It seems like the sanitizers failing is unrelated to this pr. |
// 3. If maximum is not empty and maximum < initial, throw a RangeError exception. | ||
if (descriptor.maximum.has_value()) { | ||
if (descriptor.maximum.value() < descriptor.initial) { | ||
return vm.throw_completion<JS::RangeError>("Initial is larger than maximum."sv); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need to nest these conditions:
if (descriptor.maximum.has_value() && descriptor.maximum.value() < descriptor.initial)
return vm.throw_completion<JS::RangeError>("Initial is larger than maximum."sv);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Jelle already commented the one useful thing I intended to say, so here's the nitpick:
@@ -23,6 +23,13 @@ WebIDL::ExceptionOr<GC::Ref<Memory>> Memory::construct_impl(JS::Realm& realm, Me | |||
auto& vm = realm.vm(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please rewrap the commit message and use proper capitalisation.
(maybe something like "Fixes the 'Initial value exceeds maximum' test in\n<that url>"?)
when constructing WebAssembly.Memory if initial is greater than maximum a range error will be thrown.
fixes
https://wpt.fyi/results/wasm/jsapi/memory/constructor.any.worker.html?product=ladybird Initial value exceeds maximum