Details
Description
In ValueVectorOf, it is only checked if the position of the element to be
inserted is within the range of current elements, but not if there is enough
capacity to insert the element.
To reproduce the problem:
- create ValueVectorOf with initial capacity of 1
- insertAt(0) will work for the 1st time, as addElement is called
- next insertAt(0) causes crash in the loop moving element from 0 to 1
insertAt works in this case, if addElement and removeElement are called before,
as then space for 1 element is left.
Calling ensureExtraCapacity(1); before moving the existing elements will solve
the problem.