Fix ASAN/MSAN finding due to out of bounds iterator dereference.
Fix ASAN/MSAN finding due to out of bounds iterator dereference.

PiperOrigin-RevId: 323514190

google-research/agent-based-epidemic-sim,google-research/agent-based-epidemic-sim,google-research/agent-based-epidemic-sim