Fix silent error due to invalid iterator derefencing.