Browse Source

LibJS: Verify that objects are only initialized once

We already do this in a couple of other places, we wouldn't ever want to
re-assign already initialized constructor and prototype objects.
Linus Groh 2 years ago
parent
commit
7762c1ac61
1 changed files with 2 additions and 0 deletions
  1. 2 0
      Userland/Libraries/LibJS/Runtime/Intrinsics.cpp

+ 2 - 0
Userland/Libraries/LibJS/Runtime/Intrinsics.cpp

@@ -267,6 +267,8 @@ JS_ENUMERATE_TYPED_ARRAYS
     {                                                                                                                                                    \
     {                                                                                                                                                    \
         auto& vm = this->vm();                                                                                                                           \
         auto& vm = this->vm();                                                                                                                           \
                                                                                                                                                          \
                                                                                                                                                          \
+        VERIFY(!m_##snake_namespace##snake_name##_prototype);                                                                                            \
+        VERIFY(!m_##snake_namespace##snake_name##_constructor);                                                                                          \
         if constexpr (IsTypedArrayConstructor<Namespace::ConstructorName>) {                                                                             \
         if constexpr (IsTypedArrayConstructor<Namespace::ConstructorName>) {                                                                             \
             m_##snake_namespace##snake_name##_prototype = heap().allocate<Namespace::PrototypeName>(m_realm, *typed_array_prototype());                  \
             m_##snake_namespace##snake_name##_prototype = heap().allocate<Namespace::PrototypeName>(m_realm, *typed_array_prototype());                  \
             m_##snake_namespace##snake_name##_constructor = heap().allocate<Namespace::ConstructorName>(m_realm, m_realm, *typed_array_constructor());   \
             m_##snake_namespace##snake_name##_constructor = heap().allocate<Namespace::ConstructorName>(m_realm, m_realm, *typed_array_constructor());   \