1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:27:35 +00:00

LibJS: Throw on detached viewed ArrayBuffer when validating TypedArrays

This commit is contained in:
Idan Horowitz 2021-06-17 18:27:48 +03:00 committed by Linus Groh
parent d5c836dd64
commit 2e9f665bda

View file

@ -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)