Bladeren bron

LibJS: Avoid potential signed integer overflow in CyclicModule.cpp

`auto count = 0;` will declare `count` as a `signed int`.

We don't want that since `count` is used to count the occurence of an
element in an `AK::Vector` that can have up to `SIZE_MAX` elements;
`SIZE_MAX` can overflow a `signed int` more than 4 billion times.
Emanuele Torre 3 jaren geleden
bovenliggende
commit
191566fc97
1 gewijzigde bestanden met toevoegingen van 1 en 1 verwijderingen
  1. 1 1
      Userland/Libraries/LibJS/CyclicModule.cpp

+ 1 - 1
Userland/Libraries/LibJS/CyclicModule.cpp

@@ -126,7 +126,7 @@ ThrowCompletionOr<u32> CyclicModule::inner_module_linking(VM& vm, Vector<Module*
     (void)TRY(initialize_environment(vm));
 
     // 11. Assert: module occurs exactly once in stack.
-    auto count = 0;
+    size_t count = 0;
     for (auto* module : stack) {
         if (module == this)
             count++;