more careful programming woul prevent such error by check pointers for valid values.
AnimatedSprite *hero = 0;....
display();
glutDisplayFunc(UpdateSpriteAnimation);
You better resign your code that display() only loads at startup once, and you use the GLUT-API right by drawing in the glutDisplayFunc() callback.