Fix out-of-range access.