浏览代码

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.
Florian Stellbrink 5 年之前
父节点
当前提交
17705d23fb
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. 2 2
      Libraries/LibJS/Interpreter.cpp

+ 2 - 2
Libraries/LibJS/Interpreter.cpp

@@ -122,8 +122,8 @@ void Interpreter::collect_roots(Badge<Heap>, HashTable<Cell*>& 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());
         }
     }
 }