1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 21:48:13 +00:00

LibJS: Do not allocate in Set's constructor

We are currently allocating in Set's constructor to create the set's
underlying Map. This can cause GC to occur before the member is actually
initialized, thus we will crash in Set::visit_edges trying to visit a
member that does not exist.

Instead, create the Map in Set::initialize, where we can allocate. Also
change Map to be stored as a normal JS heap-allocated object, rather
than as a stack variable.
This commit is contained in:
Timothy Flynn 2022-11-30 09:18:27 -05:00 committed by Tim Flynn
parent 715e56a74c
commit c0952e3670
3 changed files with 16 additions and 14 deletions

View file

@ -19,9 +19,6 @@ namespace JS {
class Map : public Object {
JS_OBJECT(Map, Object);
// NOTE: This awkwardness is due to Set using a Map internally.
friend class Set;
public:
static Map* create(Realm&);