From 2b92c15b340ca2b5ebaa56f8304d3d2e96f64ece Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Tue, 13 Dec 2022 20:49:49 +0000 Subject: [PATCH] LibJS: Convert Accessor::create() to NonnullGCPtr --- Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp | 4 ++-- Userland/Libraries/LibJS/Runtime/Accessor.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp b/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp index ae66f84085..a73c810628 100644 --- a/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp +++ b/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp @@ -249,7 +249,7 @@ bool validate_and_apply_property_descriptor(Object* object, PropertyKey const& p // c. If IsAccessorDescriptor(Desc) is true, then if (descriptor.is_accessor_descriptor()) { // i. Create an own accessor property named P of object O whose [[Get]], [[Set]], [[Enumerable]], and [[Configurable]] attributes are set to the value of the corresponding field in Desc if Desc has that field, or to the attribute's default value otherwise. - auto* accessor = Accessor::create(object->vm(), descriptor.get.value_or(nullptr), descriptor.set.value_or(nullptr)); + auto accessor = Accessor::create(object->vm(), descriptor.get.value_or(nullptr), descriptor.set.value_or(nullptr)); object->storage_set(property_key, { accessor, descriptor.attributes() }); } // d. Else, @@ -316,7 +316,7 @@ bool validate_and_apply_property_descriptor(Object* object, PropertyKey const& p auto enumerable = descriptor.enumerable.value_or(*current->enumerable); // iii. Replace the property named P of object O with an accessor property having [[Configurable]] and [[Enumerable]] attributes set to configurable and enumerable, respectively, and each other attribute set to its corresponding value in Desc if present, otherwise to its default value. - auto* accessor = Accessor::create(object->vm(), descriptor.get.value_or(nullptr), descriptor.set.value_or(nullptr)); + auto accessor = Accessor::create(object->vm(), descriptor.get.value_or(nullptr), descriptor.set.value_or(nullptr)); PropertyAttributes attributes; attributes.set_enumerable(enumerable); attributes.set_configurable(configurable); diff --git a/Userland/Libraries/LibJS/Runtime/Accessor.h b/Userland/Libraries/LibJS/Runtime/Accessor.h index 1ed693df4f..213627541c 100644 --- a/Userland/Libraries/LibJS/Runtime/Accessor.h +++ b/Userland/Libraries/LibJS/Runtime/Accessor.h @@ -17,9 +17,9 @@ class Accessor final : public Cell { JS_CELL(Accessor, Cell); public: - static Accessor* create(VM& vm, FunctionObject* getter, FunctionObject* setter) + static NonnullGCPtr create(VM& vm, FunctionObject* getter, FunctionObject* setter) { - return vm.heap().allocate_without_realm(getter, setter); + return *vm.heap().allocate_without_realm(getter, setter); } FunctionObject* getter() const { return m_getter; }