mirror of
https://github.com/RGBCube/serenity
synced 2025-07-02 23:22:07 +00:00
LibJS: Dont mask non-RangeError exceptions in ArrayBuffer construction
Non-RangeError exceptions can be thrown by user implementations of valueOf (which are called by to_index), and the specification disallows changing the type of the thrown error.
This commit is contained in:
parent
8dc86c6aad
commit
bc95201aaf
1 changed files with 5 additions and 3 deletions
|
@ -45,9 +45,11 @@ Value ArrayBufferConstructor::construct(Function&)
|
|||
auto& vm = this->vm();
|
||||
auto byte_length = vm.argument(0).to_index(global_object());
|
||||
if (vm.exception()) {
|
||||
// Re-throw more specific RangeError
|
||||
vm.clear_exception();
|
||||
vm.throw_exception<RangeError>(global_object(), ErrorType::InvalidLength, "array buffer");
|
||||
if (vm.exception()->value().is_object() && is<RangeError>(vm.exception()->value().as_object())) {
|
||||
// Re-throw more specific RangeError
|
||||
vm.clear_exception();
|
||||
vm.throw_exception<RangeError>(global_object(), ErrorType::InvalidLength, "array buffer");
|
||||
}
|
||||
return {};
|
||||
}
|
||||
return ArrayBuffer::create(global_object(), byte_length);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue