diff --git a/js/src/vm/RegExpObject.cpp b/js/src/vm/RegExpObject.cpp index b75d4f3b32..cea90a29e1 100644 --- a/js/src/vm/RegExpObject.cpp +++ b/js/src/vm/RegExpObject.cpp @@ -958,16 +958,17 @@ RegExpShared::RegExpShared(JSAtom* source, RegExpFlag flags) {} struct RegExpShared::NamedCaptureData { - bool mapInited; // per-compartment template cache (optional; you can also skip templates entirely) using GroupsTemplateMap = GCHashMap, DefaultHasher, SystemAllocPolicy>; GroupsTemplateMap groupsTemplateMap; - bool groupsTemplateMapInited = false; + bool groupsTemplateMapInited; Vector names; Vector indices; + + NamedCaptureData() : groupsTemplateMapInited(false) {} }; void @@ -977,7 +978,7 @@ RegExpShared::traceChildren(JSTracer* trc) if (IsMarkingTrace(trc) && trc->runtime()->gc.isShrinkingGC()) discardJitCode(); - if (namedCaptureData_ && namedCaptureData_->mapInited) { + if (namedCaptureData_ && namedCaptureData_->groupsTemplateMapInited) { for (auto iter = namedCaptureData_->groupsTemplateMap.all(); !iter.empty(); iter.popFront()) { TraceNullableEdge(trc, &iter.front().value(), "RegExpShared groupsTemplate per-compartment"); } @@ -985,7 +986,7 @@ RegExpShared::traceChildren(JSTracer* trc) for (auto& atom : namedCaptureNames_) { TraceEdge(trc, &atom, "RegExpShared namedCaptureName"); - } + } TraceNullableEdge(trc, &source, "RegExpShared source"); for (auto& comp : compilationArray) @@ -1005,6 +1006,10 @@ RegExpShared::discardJitCode() void RegExpShared::finalize(FreeOp* fop) { + if (namedCaptureData_) { + js_delete(namedCaptureData_); + namedCaptureData_ = nullptr; + } for (auto& comp : compilationArray) js_free(comp.byteCode); tables.~JitCodeTables(); @@ -1401,10 +1406,10 @@ RegExpShared::getOrCreateGroupsTemplate(JSContext* cx) NamedCaptureData* data = namedCaptureData_; - if (!data->mapInited) { + if (!data->groupsTemplateMapInited) { if (!data->groupsTemplateMap.init(4)) return nullptr; - data->mapInited = true; + data->groupsTemplateMapInited = true; } JSCompartment* comp = cx->compartment();