It is safe to cast up the length integer to size_t here because we have already checked that it is greater than zero.