diff options
author | Idan Horowitz <idan.horowitz@gmail.com> | 2021-06-17 18:27:48 +0300 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-06-18 20:17:45 +0100 |
commit | 2e9f665bda041ad2e9ee70ecabbaf96a18a7a2ec (patch) | |
tree | 13657b196c4399a1a71c801ceb517e3ba78e7e99 /Userland | |
parent | d5c836dd6474190baac78e2949bb150aa2d6e8d8 (diff) | |
download | serenity-2e9f665bda041ad2e9ee70ecabbaf96a18a7a2ec.zip |
LibJS: Throw on detached viewed ArrayBuffer when validating TypedArrays
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp | 7 |
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) |