浏览代码

LibJS: Only initialize in add_constructor() if not already done

Linus Groh 4 年之前
父节点
当前提交
2f03eb8628
共有 1 个文件被更改,包括 3 次插入1 次删除
  1. 3 1
      Userland/Libraries/LibJS/Runtime/GlobalObject.h

+ 3 - 1
Userland/Libraries/LibJS/Runtime/GlobalObject.h

@@ -111,7 +111,9 @@ inline void GlobalObject::initialize_constructor(const FlyString& property_name,
 template<typename ConstructorType>
 template<typename ConstructorType>
 inline void GlobalObject::add_constructor(const FlyString& property_name, ConstructorType*& constructor, Object* prototype)
 inline void GlobalObject::add_constructor(const FlyString& property_name, ConstructorType*& constructor, Object* prototype)
 {
 {
-    initialize_constructor(property_name, constructor, prototype);
+    // Some constructors are pre-initialized separately.
+    if (!constructor)
+        initialize_constructor(property_name, constructor, prototype);
     define_property(property_name, constructor, Attribute::Writable | Attribute::Configurable);
     define_property(property_name, constructor, Attribute::Writable | Attribute::Configurable);
 }
 }