summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorIdan Horowitz <idan.horowitz@gmail.com>2021-06-17 18:27:48 +0300
committerLinus Groh <mail@linusgroh.de>2021-06-18 20:17:45 +0100
commit2e9f665bda041ad2e9ee70ecabbaf96a18a7a2ec (patch)
tree13657b196c4399a1a71c801ceb517e3ba78e7e99 /Userland
parentd5c836dd6474190baac78e2949bb150aa2d6e8d8 (diff)
downloadserenity-2e9f665bda041ad2e9ee70ecabbaf96a18a7a2ec.zip
LibJS: Throw on detached viewed ArrayBuffer when validating TypedArrays
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp b/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp
index f5e559697a..e438a069db 100644
--- a/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp
@@ -53,7 +53,12 @@ static TypedArrayBase* typed_array_from(VM& vm, GlobalObject& global_object)
vm.throw_exception<TypeError>(global_object, ErrorType::NotA, "TypedArray");
return nullptr;
}
- return static_cast<TypedArrayBase*>(this_object);
+ auto* typed_array = static_cast<TypedArrayBase*>(this_object);
+ if (typed_array->viewed_array_buffer()->is_detached()) {
+ vm.throw_exception<TypeError>(global_object, ErrorType::DetachedArrayBuffer);
+ return nullptr;
+ }
+ return typed_array;
}
static Function* callback_from_args(GlobalObject& global_object, const String& name)