From 484b7a4f0183d4a2aae735dcf3addaa02f7e2acd Mon Sep 17 00:00:00 2001 From: Ichiro Date: Mon, 30 Sep 2024 01:10:03 +0900 Subject: [PATCH] Prevent crash on Animation --- OgreMain/src/OgreAnimation.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/OgreMain/src/OgreAnimation.cpp b/OgreMain/src/OgreAnimation.cpp index 2238afd49ce..ccd31a14d80 100644 --- a/OgreMain/src/OgreAnimation.cpp +++ b/OgreMain/src/OgreAnimation.cpp @@ -607,6 +607,10 @@ namespace Ogre { if( timePos > totalAnimationLength && totalAnimationLength > 0.0f ) timePos = std::fmod( timePos, totalAnimationLength ); + // Not best practice, but prevent from crash + if (mKeyFrameTimes.empty()) + return timePos; + // Search for global index auto it = std::lower_bound(mKeyFrameTimes.begin(), mKeyFrameTimes.end() - 1, timePos); return TimeIndex(timePos, static_cast(std::distance(mKeyFrameTimes.begin(), it)));