cppcheck: Iterator it used after element has been erased

Change-Id: Id0a0b026cd25f210df4bd821c2ca28edf3dee693
Reviewed-on: https://gerrit.libreoffice.org/9110
Tested-by: David Tardon <dtardon@redhat.com>
Reviewed-by: David Tardon <dtardon@redhat.com>