From 860417fb4fb9917fd08a6df2d70ab5c22935cfa8 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Fri, 16 Jul 2021 14:36:52 -0400 Subject: [PATCH] LibJS: Ensure RegExpStringIterator keeps the RegExp matcher object alive Fixes a crash found with 'test-js -g' due to this object going out of scope. --- Userland/Libraries/LibJS/Runtime/RegExpStringIterator.cpp | 6 ++++++ Userland/Libraries/LibJS/Runtime/RegExpStringIterator.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/Userland/Libraries/LibJS/Runtime/RegExpStringIterator.cpp b/Userland/Libraries/LibJS/Runtime/RegExpStringIterator.cpp index 573e7bb32e..ed5a0bcdd2 100644 --- a/Userland/Libraries/LibJS/Runtime/RegExpStringIterator.cpp +++ b/Userland/Libraries/LibJS/Runtime/RegExpStringIterator.cpp @@ -24,4 +24,10 @@ RegExpStringIterator::RegExpStringIterator(Object& prototype, Object& regexp_obj { } +void RegExpStringIterator::visit_edges(Cell::Visitor& visitor) +{ + Object::visit_edges(visitor); + visitor.visit(&m_regexp_object); +} + } diff --git a/Userland/Libraries/LibJS/Runtime/RegExpStringIterator.h b/Userland/Libraries/LibJS/Runtime/RegExpStringIterator.h index 876dd796a9..fec3bd44e3 100644 --- a/Userland/Libraries/LibJS/Runtime/RegExpStringIterator.h +++ b/Userland/Libraries/LibJS/Runtime/RegExpStringIterator.h @@ -28,6 +28,8 @@ public: void set_done() { m_done = true; } private: + virtual void visit_edges(Cell::Visitor&) override; + Object& m_regexp_object; String m_string; bool m_global { false };