diff --git a/Userland/Libraries/LibJS/AST.cpp b/Userland/Libraries/LibJS/AST.cpp index a2f6c0f567..65fae457ad 100644 --- a/Userland/Libraries/LibJS/AST.cpp +++ b/Userland/Libraries/LibJS/AST.cpp @@ -3541,7 +3541,7 @@ Completion RegExpLiteral::execute(Interpreter& interpreter) const // 3. Return ! RegExpCreate(pattern, flags). Regex regex(parsed_regex(), parsed_pattern(), parsed_flags()); // NOTE: We bypass RegExpCreate and subsequently RegExpAlloc as an optimization to use the already parsed values. - auto* regexp_object = RegExpObject::create(realm, move(regex), move(pattern), move(flags)); + auto regexp_object = RegExpObject::create(realm, move(regex), move(pattern), move(flags)); // RegExpAlloc has these two steps from the 'Legacy RegExp features' proposal. regexp_object->set_realm(*vm.current_realm()); // We don't need to check 'If SameValue(newTarget, thisRealm.[[Intrinsics]].[[%RegExp%]]) is true' diff --git a/Userland/Libraries/LibJS/Runtime/RegExpObject.cpp b/Userland/Libraries/LibJS/Runtime/RegExpObject.cpp index 979081ab1d..3cf1a687d4 100644 --- a/Userland/Libraries/LibJS/Runtime/RegExpObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/RegExpObject.cpp @@ -124,14 +124,14 @@ ThrowCompletionOr parse_regex_pattern(VM& vm, StringView patte return result.release_value(); } -RegExpObject* RegExpObject::create(Realm& realm) +NonnullGCPtr RegExpObject::create(Realm& realm) { - return realm.heap().allocate(realm, *realm.intrinsics().regexp_prototype()); + return *realm.heap().allocate(realm, *realm.intrinsics().regexp_prototype()); } -RegExpObject* RegExpObject::create(Realm& realm, Regex regex, DeprecatedString pattern, DeprecatedString flags) +NonnullGCPtr RegExpObject::create(Realm& realm, Regex regex, DeprecatedString pattern, DeprecatedString flags) { - return realm.heap().allocate(realm, move(regex), move(pattern), move(flags), *realm.intrinsics().regexp_prototype()); + return *realm.heap().allocate(realm, move(regex), move(pattern), move(flags), *realm.intrinsics().regexp_prototype()); } RegExpObject::RegExpObject(Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/RegExpObject.h b/Userland/Libraries/LibJS/Runtime/RegExpObject.h index 144dc77f5c..eadb108e53 100644 --- a/Userland/Libraries/LibJS/Runtime/RegExpObject.h +++ b/Userland/Libraries/LibJS/Runtime/RegExpObject.h @@ -36,8 +36,8 @@ public: | regex::ECMAScriptFlags::BrowserExtended }; - static RegExpObject* create(Realm&); - static RegExpObject* create(Realm&, Regex regex, DeprecatedString pattern, DeprecatedString flags); + static NonnullGCPtr create(Realm&); + static NonnullGCPtr create(Realm&, Regex regex, DeprecatedString pattern, DeprecatedString flags); ThrowCompletionOr> regexp_initialize(VM&, Value pattern, Value flags); DeprecatedString escape_regexp_pattern() const;