Your problem are the following 5 lines:
keyArray[?][5] = '?';
where you are indexing out of the boundaries of your keyArray
array. It has probably overwritten an internal pointer in the paddedVector
object. In turn when the vector tries to (re)allocate memory, you get this exception because delete[]
cannot understand where that address came from.
Note that for the same reason you started your first index from 0
, you should also start your second index from 0
! Therefore, both indices should be in the range [0, 5)
.