Do not modify vector while iterating over it in range-based for loop

Merged David Redondo requested to merge work/loop into Plasma/5.19

This is undefined behavior leading to wrong behavior or crashes. Instead iterate backwards to not invalidate iterators that are still to be accessed.

BUG: 423224

BUG: 423441

Edited by David Redondo

Merge request reports