1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 12:38:12 +00:00

LibJS: Stop fetching GlobalObject from target's realm in ArrayBuffer

A function object's realm is not necessarily non-null (like when called
via the Reflect API), so we can't blindly dereference it. Instead use
the object's own GlobalObject.
This commit is contained in:
Idan Horowitz 2022-04-30 20:06:57 +03:00 committed by Linus Groh
parent 9098257668
commit 1a8b5ef80a

View file

@ -65,7 +65,7 @@ static ThrowCompletionOr<Optional<size_t>> get_array_buffer_max_byte_length_opti
// 1.2.1 ArrayBuffer ( length [, options ] ), https://tc39.es/proposal-resizablearraybuffer/#sec-arraybuffer-constructor
ThrowCompletionOr<Object*> ArrayBufferConstructor::construct(FunctionObject& new_target)
{
auto& global_object = new_target.realm()->global_object();
auto& global_object = this->global_object();
auto& vm = this->vm();
// 1. If NewTarget is undefined, throw a TypeError exception.