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.
This commit is contained in:
Emanuele Torre 2022-01-22 02:35:24 +01:00 committed by Andreas Kling
parent 065525aba0
commit 191566fc97
Notes: sideshowbarker 2024-07-17 20:27:28 +09:00

View file

@ -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++;