From 3bffe3a05da442a0e811eab52efca8b0935eb703 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D1=80=D0=B0=D0=BD=D0=B8=D0=BC=D0=B8=D1=80=20=D0=9A?= =?UTF-8?q?=D0=B0=D1=80=D0=B0=D1=9F=D0=B8=D1=9B?= Date: Fri, 13 Nov 2020 20:53:11 -0800 Subject: [PATCH] Fixed undefined behavior. --- tools/texturev/texturev.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tools/texturev/texturev.cpp b/tools/texturev/texturev.cpp index c4a918227..eeabff0f6 100644 --- a/tools/texturev/texturev.cpp +++ b/tools/texturev/texturev.cpp @@ -1104,11 +1104,16 @@ struct InterpolatorT bool isActive() const { - const double freq = double(bx::getHPFrequency() ); - int64_t now = bx::getHPCounter(); - float time = (float)(double(now - offset) / freq); - float lerp = bx::clamp(time, 0.0f, duration) / duration; - return lerp < 1.0f; + if (0.0f < duration) + { + const double freq = double(bx::getHPFrequency() ); + int64_t now = bx::getHPCounter(); + float time = (float)(double(now - offset) / freq); + float lerp = bx::clamp(time, 0.0f, duration) / duration; + return lerp < 1.0f; + } + + return false; } };