- Editado
Trying to load an unexisting animation crash runtime-c
Hi,
if you try lo load, or add, an unexisting animation with the runtime-c the program crash because it access to an invalid pointer.
Here is the fix:
https://github.com/Darky-Lucera/spine-r ... 05b3084347
Thanks
I don't think all methods should accept null pointers and simply do nothing if passed null. The rule is you can never pass null as a parameter unless the method documentation explicitly says it accepts null.
The problem is not that I'm trying to pass null to this function. The problem is that the runtime does it.
If the user calls spAnimationState_setAnimationByName or spAnimationState_addAnimationByName with a non existent animation name the runtime fails:
Your code does not check if animation is valid:
spTrackEntry* spAnimationState_setAnimationByName (spAnimationState* self, int trackIndex, const char* animationName,
int/[i]bool[/i]/loop) {
spAnimation* animation = spSkeletonData_findAnimation(self->data->skeletonData, animationName);
return spAnimationState_setAnimation(self, trackIndex, animation, loop);
}
spTrackEntry* spAnimationState_addAnimationByName (spAnimationState* self, int trackIndex, const char* animationName,
int/[i]bool[/i]/loop, float delay) {
spAnimation* animation = spSkeletonData_findAnimation(self->data->skeletonData, animationName);
return spAnimationState_addAnimation(self, trackIndex, animation, loop, delay);
}