Fixed memory error caused by token lists prematurely reaching the end, hence dereferencing a NULL pointer.