Skip to content

Commit ab00a4d

Browse files
tcl3awesomekling
authored andcommitted
LibJS: Skip null entries in numeric string cache when gathering roots
This caused a crash when dumping the GC graph.
1 parent 9ff75f4 commit ab00a4d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Libraries/LibJS/Runtime/VM.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,12 @@ void VM::gather_roots(HashMap<GC::Cell*, GC::HeapRoot>& roots)
246246
for (auto string : m_single_ascii_character_strings)
247247
roots.set(string, GC::HeapRoot { .type = GC::HeapRoot::Type::VM });
248248

249-
for (auto string : m_numeric_string_cache)
249+
for (auto string : m_numeric_string_cache) {
250+
// The numeric string cache is populated lazily, so skip null entries.
251+
if (!string)
252+
continue;
250253
roots.set(string, GC::HeapRoot { .type = GC::HeapRoot::Type::VM });
254+
}
251255

252256
roots.set(cached_strings.number, GC::HeapRoot { .type = GC::HeapRoot::Type::VM });
253257
roots.set(cached_strings.undefined, GC::HeapRoot { .type = GC::HeapRoot::Type::VM });

0 commit comments

Comments
 (0)