For some reason, this old Coverity issue was already marked as solved. Also it is slightly more effective to store the end pointer than evaluate in every pass.