valid indexes on originalExtension if it is declared to be 21 elements would be 0-20. by writing the null in the 21 element you are writing it off the end of the buffer (which explains the stack error).