WinRT: Fixed possible integer overflow in timer registration code
authorOliver Wolff <oliver.wolff@theqtcompany.com>
Tue, 1 Sep 2015 06:49:31 +0000 (08:49 +0200)
committerOliver Wolff <oliver.wolff@theqtcompany.com>
Wed, 2 Sep 2015 10:21:37 +0000 (10:21 +0000)
Task-number: QTBUG-48012
Change-Id: If1b80e59c13230bc0a62c6fa3d45b6e2272b9e28
Reviewed-by: Andrew Knight <andrew.knight@intopalo.com>
src/corelib/kernel/qeventdispatcher_winrt.cpp

index f771974a244aee45333270b4eb2edc35c1745b88..490a7c566a01c49857b7e2df642ce859434428e3 100644 (file)
@@ -288,7 +288,8 @@ void QEventDispatcherWinRT::registerTimer(int timerId, int interval, Qt::TimerTy
     }
 
     TimeSpan period;
-    period.Duration = interval ? (interval * 10000) : 1; // TimeSpan is based on 100-nanosecond units
+    // TimeSpan is based on 100-nanosecond units
+    period.Duration = qMax(qint64(1), qint64(interval) * 10000);
     const HANDLE handle = CreateEventEx(NULL, NULL, CREATE_EVENT_MANUAL_RESET, SYNCHRONIZE | EVENT_MODIFY_STATE);
     const HANDLE cancelHandle = CreateEventEx(NULL, NULL, CREATE_EVENT_MANUAL_RESET, SYNCHRONIZE|EVENT_MODIFY_STATE);
     HRESULT hr = runOnXamlThread([&]() {