[RewriteStatepointsForGC] Fix iterator invalidation bug