summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorIdan Horowitz <idan.horowitz@gmail.com>2021-09-24 01:41:54 +0300
committerIdan Horowitz <idan.horowitz@gmail.com>2021-09-24 02:28:17 +0300
commit5f80d8245d1bcdb5b205368ffc2d95acbf3cf59d (patch)
tree3e899f8b3dcd39436ff9e6dcb8957674c03b013e /Userland/Libraries
parent99bc429f3f18743963a484152ff4067f9c610156 (diff)
downloadserenity-5f80d8245d1bcdb5b205368ffc2d95acbf3cf59d.zip
LibJS: Close iterator on throw completion in Array.from
This regressed in #10190
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp
index 22359d9bd1..e4eab82991 100644
--- a/Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp
@@ -149,11 +149,12 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayConstructor::from)
Value mapped_value;
if (map_fn) {
- mapped_value = TRY_OR_DISCARD(vm.call(*map_fn, this_arg, next_value, Value(k)));
- if (vm.exception()) {
+ auto mapped_value_or_error = vm.call(*map_fn, this_arg, next_value, Value(k));
+ if (mapped_value_or_error.is_error()) {
iterator_close(*iterator);
return {};
}
+ mapped_value = mapped_value_or_error.release_value();
} else {
mapped_value = next_value;
}