Fix infinite loop introduced in [9142f0c6]