summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2021-06-27 20:53:29 +0100
committerLinus Groh <mail@linusgroh.de>2021-06-27 21:01:01 +0100
commit93bae37dd91d84df26a6ef78964888f87a996933 (patch)
tree28341ac35fcda092920e3b5a2beb94df94cb7b51 /Userland
parent48e7fd52e748609f96a23e5c7f39f5a8213d98b4 (diff)
downloadserenity-93bae37dd91d84df26a6ef78964888f87a996933.zip
LibJS: Add 'is detached' check to InitializeTypedArrayFromTypedArray()
Resolves a FIXME.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibJS/Runtime/TypedArray.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/TypedArray.cpp b/Userland/Libraries/LibJS/Runtime/TypedArray.cpp
index 5922b5e82e..8a2f0ee895 100644
--- a/Userland/Libraries/LibJS/Runtime/TypedArray.cpp
+++ b/Userland/Libraries/LibJS/Runtime/TypedArray.cpp
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
- * Copyright (c) 2020, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2020-2021, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -103,10 +103,14 @@ static void initialize_typed_array_from_typed_array(GlobalObject& global_object,
return;
}
- // FIXME: 17.b If IsDetachedBuffer(array_buffer) is true, throw a TypeError exception.
// FIXME: 17.c If src_array.[[ContentType]] != dest_array.[[ContentType]], throw a TypeError exception.
auto data = ArrayBuffer::create(global_object, byte_length.value());
+ if (src_data->is_detached()) {
+ vm.throw_exception<TypeError>(global_object, ErrorType::DetachedArrayBuffer);
+ return;
+ }
+
dest_array.set_viewed_array_buffer(data);
dest_array.set_byte_length(byte_length.value());
dest_array.set_byte_offset(0);