Even with SetErrorMode(2) on at the beggining of the program the spriteanimation function doesnt always catch the illegal number of frames. He is right that there is a bug
Depending on the image dimensions you may get
But with some images it silently passes the setting of a number of images that cant exist as the image isnt big enough then attempts to play them. This results in some legitimate frames being played followed by a last frame that shows very little (UV coords outside 1.0,1.0).
So the OP is correct... the checking of a valid number of frames isnt quite what it should be but it does depend on image dimensions it would seem.