mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 20:29:18 +00:00
LibJS: Add missing exception checks to {Array, TypedArray}.from()
This commit is contained in:
parent
ee825d6d9e
commit
99bc429f3f
Notes:
sideshowbarker
2024-07-18 03:30:58 +09:00
Author: https://github.com/IdanHo
Commit: 99bc429f3f
Pull-request: https://github.com/SerenityOS/serenity/pull/10192
Reviewed-by: https://github.com/davidot ✅
2 changed files with 4 additions and 0 deletions
|
@ -189,6 +189,8 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayConstructor::from)
|
||||||
|
|
||||||
for (size_t k = 0; k < length; ++k) {
|
for (size_t k = 0; k < length; ++k) {
|
||||||
auto k_value = array_like->get(k);
|
auto k_value = array_like->get(k);
|
||||||
|
if (vm.exception())
|
||||||
|
return {};
|
||||||
Value mapped_value;
|
Value mapped_value;
|
||||||
if (map_fn)
|
if (map_fn)
|
||||||
mapped_value = TRY_OR_DISCARD(vm.call(*map_fn, this_arg, k_value, Value(k)));
|
mapped_value = TRY_OR_DISCARD(vm.call(*map_fn, this_arg, k_value, Value(k)));
|
||||||
|
|
|
@ -115,6 +115,8 @@ JS_DEFINE_NATIVE_FUNCTION(TypedArrayConstructor::from)
|
||||||
|
|
||||||
for (size_t k = 0; k < length; ++k) {
|
for (size_t k = 0; k < length; ++k) {
|
||||||
auto k_value = array_like->get(k);
|
auto k_value = array_like->get(k);
|
||||||
|
if (vm.exception())
|
||||||
|
return {};
|
||||||
Value mapped_value;
|
Value mapped_value;
|
||||||
if (map_fn)
|
if (map_fn)
|
||||||
mapped_value = TRY_OR_DISCARD(vm.call(*map_fn, this_arg, k_value, Value(k)));
|
mapped_value = TRY_OR_DISCARD(vm.call(*map_fn, this_arg, k_value, Value(k)));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue