c++ - Debug Assertion Failed! Expression: __BLOCK_TYPE_IS_VALID(pHead->nBlockUse) when deleting -


my friend , updating our tetris project more dynamic (allow size shapes instead of 4 tiled shapes), upgrading arrays vectors. worked fine before error title whenever shape reaches floor. exact line of code happens (the delete[] currentshape):

main.cpp      if (currentshape != null) {         delete[] currentshape; // breaks here     }     currentshape = new shape; 

the whole project bit long here on pastebin:

edit: breaks on line 167 if hold since has same code, shouldn't have bug.

when delete debug heap checks pointer , checks allocated region plus "guard" space before , after region. detected wrong such write out of bounds. have happened anywhere prior delete step. must trace , debug access array looking error writes outside of array.