From 7d9e4073ab353ec9393f235ad2c703c22bb5ffed Mon Sep 17 00:00:00 2001 From: Hans-Joachim Krauch Date: Thu, 10 May 2018 22:07:35 +0200 Subject: [PATCH] Fix integer overflow for oneshot timers. (#1382) * Template std::max instead of casting explicitly. --- clients/roscpp/include/ros/timer_manager.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/roscpp/include/ros/timer_manager.h b/clients/roscpp/include/ros/timer_manager.h index 27f8ca1f64..354c7daad1 100644 --- a/clients/roscpp/include/ros/timer_manager.h +++ b/clients/roscpp/include/ros/timer_manager.h @@ -576,7 +576,7 @@ void TimerManager::threadFunc() { // On system time we can simply sleep for the rest of the wait time, since anything else requiring processing will // signal the condition variable - int32_t remaining_time = std::max((int32_t)((sleep_end - current).toSec() * 1000.0f), 1); + int64_t remaining_time = std::max((sleep_end - current).toSec() * 1000.0f, 1); timers_cond_.timed_wait(lock, boost::posix_time::milliseconds(remaining_time)); } }