From 17705d23fbe700d03bcf32a79bb63a2b074e44b9 Mon Sep 17 00:00:00 2001 From: Florian Stellbrink Date: Thu, 12 Mar 2020 02:03:48 +0100 Subject: [PATCH] LibJS: Fix string roots not being collected Previously objects were the only heap allocated value. Now there are also strings. This replaces a usage of is_object with is_cell. Without this change strings could be garbage collected while still being used in an active scope. --- Libraries/LibJS/Interpreter.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Libraries/LibJS/Interpreter.cpp b/Libraries/LibJS/Interpreter.cpp index 3983998c55..6c3ab98dfe 100644 --- a/Libraries/LibJS/Interpreter.cpp +++ b/Libraries/LibJS/Interpreter.cpp @@ -122,8 +122,8 @@ void Interpreter::collect_roots(Badge, HashTable& roots) for (auto& scope : m_scope_stack) { for (auto& it : scope.variables) { - if (it.value.is_object()) - roots.set(it.value.as_object()); + if (it.value.is_cell()) + roots.set(it.value.as_cell()); } } }