From 99bc429f3f18743963a484152ff4067f9c610156 Mon Sep 17 00:00:00 2001 From: Idan Horowitz Date: Fri, 24 Sep 2021 01:39:34 +0300 Subject: [PATCH] LibJS: Add missing exception checks to {Array, TypedArray}.from() --- Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp | 2 ++ Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp index 2e92962e1a..22359d9bd1 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp @@ -189,6 +189,8 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayConstructor::from) for (size_t k = 0; k < length; ++k) { auto k_value = array_like->get(k); + if (vm.exception()) + return {}; Value mapped_value; if (map_fn) mapped_value = TRY_OR_DISCARD(vm.call(*map_fn, this_arg, k_value, Value(k))); diff --git a/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.cpp b/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.cpp index c6b5b13f0b..c39425548b 100644 --- a/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.cpp @@ -115,6 +115,8 @@ JS_DEFINE_NATIVE_FUNCTION(TypedArrayConstructor::from) for (size_t k = 0; k < length; ++k) { auto k_value = array_like->get(k); + if (vm.exception()) + return {}; Value mapped_value; if (map_fn) mapped_value = TRY_OR_DISCARD(vm.call(*map_fn, this_arg, k_value, Value(k)));