Running the while loop up to NUM_ITERS
times may set iter
to g_outpoints.size()
, which will then lead to an out-of-bounds read.
There was an assert, which I guess tried to catch this, but the condition in the assert was wrong as well.
Fix all issues by replacing the broken assert with the internal and correct check inside std::vector::at
and by limiting iter
to NUM_ITERS
in the while loop.