Fix input index bounds check.