Fix an IndexOutOfRange exception.