Skip to content

Commit

Permalink
Fix integer overflow for oneshot timers. (#1382)
Browse files Browse the repository at this point in the history
* Template std::max instead of casting explicitly.
  • Loading branch information
achim-k authored and dirk-thomas committed Aug 9, 2018
1 parent 3ce36e3 commit 7d9e407
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion clients/roscpp/include/ros/timer_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ void TimerManager<T, D, E>::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<int64_t>((sleep_end - current).toSec() * 1000.0f, 1);
timers_cond_.timed_wait(lock, boost::posix_time::milliseconds(remaining_time));
}
}
Expand Down

0 comments on commit 7d9e407

Please sign in to comment.