From 5646c781c88ab0f0427f23102bea889a835bd378 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Tue, 7 Jan 2020 15:16:05 +0200 Subject: [PATCH] [nightcolor] Fix division by zero Summary: If qAbs(targetTemp - m_currentTemp) is less than TEMPERATURE_STEP, then it will result in a division by zero. FIXED-IN: 5.17.5 BUG: 415359 Reviewers: #kwin, apol Reviewed By: apol Subscribers: kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D26493 --- colorcorrection/manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/colorcorrection/manager.cpp b/colorcorrection/manager.cpp index 50b304ca0e..79e9a1428c 100644 --- a/colorcorrection/manager.cpp +++ b/colorcorrection/manager.cpp @@ -408,7 +408,7 @@ void Manager::resetSlowUpdateTimer() } // calculate interval such as temperature is changed by TEMPERATURE_STEP K per timer timeout - int interval = availTime / (qAbs(targetTemp - m_currentTemp) / TEMPERATURE_STEP); + int interval = availTime * TEMPERATURE_STEP / qAbs(targetTemp - m_currentTemp); if (interval == 0) { interval = 1; }