I've attached my poor, poor layman's excuse for a tokeniser. I've got no idea where this heap problem it coming from, except that visual studio pops up a heap corruption-type dialog box when I step into "delete t;" (in main.cpp).
After looking at the output window (for more information) I've worked out that I'm overwriting the source buffer somewhere (the displayed size grows and shrinks as I add / remove from test.txt).
NOTE: Attachment is a .zip masquerading as a .txt.