From 96b071bdb1965084c6e78073f9f42a872300f308 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Wed, 4 Jan 2023 09:19:37 +0100 Subject: [PATCH] Fix: Fix possible division by zero - closes https://github.com/assimp/assimp/issues/4860 --- code/AssetLib/LWO/LWOAnimation.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/code/AssetLib/LWO/LWOAnimation.cpp b/code/AssetLib/LWO/LWOAnimation.cpp index f729f84b1..7ebbfb810 100644 --- a/code/AssetLib/LWO/LWOAnimation.cpp +++ b/code/AssetLib/LWO/LWOAnimation.cpp @@ -162,8 +162,11 @@ void AnimResolver::UpdateAnimRangeSetup() { const double my_last = (*it).keys.back().time; const double delta = my_last - my_first; + if (delta == 0.0) { + continue; + } + const size_t old_size = (*it).keys.size(); - const float value_delta = (*it).keys.back().value - (*it).keys.front().value; // NOTE: We won't handle reset, linear and constant here. @@ -176,8 +179,7 @@ void AnimResolver::UpdateAnimRangeSetup() { case LWO::PrePostBehaviour_Oscillate: { const double start_time = delta - std::fmod(my_first - first, delta); std::vector::iterator n = std::find_if((*it).keys.begin(), (*it).keys.end(), - [start_time](double t) { return start_time > t; }), - m; + [start_time](double t) { return start_time > t; }), m; size_t ofs = 0; if (n != (*it).keys.end()) {