The first thing to do in such cases is debugging. Anything could be an engine bug, but you'll never know unless you look where the problem lies at all. I can help when I know where the problem happens, and under which circumstances.

"Invalid pointer" means that a pointer is NULL. The first thing to do is finding when and where in the code that pointer is set to NULL. Display the pointer on the screen, like this:

draw_text(str_for_num(NULL,player),10,10,vector(0,0,0))

and check if and when "player" changes.