Why is this upper loop bound inclusive? It appears to me that it will access an element beyond the end of the array.