Cppcheck: fix iterator used after element erased

Change-Id: I44922ce1b399fce0bd42342e43e2e29b22cf06c2
Merge topic 'cppcheck_iterator_reused' into master

8e4b34f0 Cppcheck: fix iterator used after element erased