LibJS: Skip null entries in numeric string cache when gathering roots

This caused a crash when dumping the GC graph.
This commit is contained in:
Tim Ledbetter 2025-11-04 00:45:21 +00:00 committed by Andreas Kling
parent 9ff75f442b
commit ab00a4dc1f
Notes: github-actions[bot] 2025-11-04 09:35:45 +00:00

View file

@ -246,8 +246,12 @@ void VM::gather_roots(HashMap<GC::Cell*, GC::HeapRoot>& roots)
for (auto string : m_single_ascii_character_strings)
roots.set(string, GC::HeapRoot { .type = GC::HeapRoot::Type::VM });
for (auto string : m_numeric_string_cache)
for (auto string : m_numeric_string_cache) {
// The numeric string cache is populated lazily, so skip null entries.
if (!string)
continue;
roots.set(string, GC::HeapRoot { .type = GC::HeapRoot::Type::VM });
}
roots.set(cached_strings.number, GC::HeapRoot { .type = GC::HeapRoot::Type::VM });
roots.set(cached_strings.undefined, GC::HeapRoot { .type = GC::HeapRoot::Type::VM });