diff --git a/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp index aeab875a0d..adcd71ce6b 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp @@ -863,7 +863,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::group_to_map) } // 7. Let map be ! Construct(%Map%). - auto* map = Map::create(realm); + auto map = Map::create(realm); // 8. For each Record { [[Key]], [[Elements]] } g of groups, do for (auto& group : groups) { diff --git a/Userland/Libraries/LibJS/Runtime/Map.cpp b/Userland/Libraries/LibJS/Runtime/Map.cpp index 076d963a97..87fc6edbc7 100644 --- a/Userland/Libraries/LibJS/Runtime/Map.cpp +++ b/Userland/Libraries/LibJS/Runtime/Map.cpp @@ -8,9 +8,9 @@ namespace JS { -Map* Map::create(Realm& realm) +NonnullGCPtr Map::create(Realm& realm) { - return realm.heap().allocate(realm, *realm.intrinsics().map_prototype()); + return *realm.heap().allocate(realm, *realm.intrinsics().map_prototype()); } Map::Map(Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/Map.h b/Userland/Libraries/LibJS/Runtime/Map.h index c2d12d910f..3a8db6976a 100644 --- a/Userland/Libraries/LibJS/Runtime/Map.h +++ b/Userland/Libraries/LibJS/Runtime/Map.h @@ -20,7 +20,7 @@ class Map : public Object { JS_OBJECT(Map, Object); public: - static Map* create(Realm&); + static NonnullGCPtr create(Realm&); virtual ~Map() override = default;