Avoid using invalidated iterators.

The iterator implicit in the ranged for() can be invalidated by the eraseFromParent() call. Trying to advance it constitutes a use-after-free.

Found by valgrind.

Merge request reports

Loading