Skip to content

Commit

Permalink
possible division by zero fixed
Browse files Browse the repository at this point in the history
crash appears for time deltas < 1 ms
  • Loading branch information
rex-schilasky authored and FlorianReimold committed Mar 16, 2021
1 parent a73ece6 commit c296fe1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
3 changes: 1 addition & 2 deletions ecal/core/src/readwrite/ecal_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -666,8 +666,7 @@ namespace eCAL
// ensure that registration is not called within zero nanoseconds
// normally it will be called from registration logic every second
auto curr_time = std::chrono::steady_clock::now();
auto diff_time = curr_time - m_rec_time;
if(diff_time > std::chrono::nanoseconds::zero())
if (std::chrono::duration_cast<std::chrono::milliseconds>(curr_time - m_rec_time) > std::chrono::milliseconds(0))
{
// reset clock and time on first call
if (m_clock_old == 0)
Expand Down
3 changes: 1 addition & 2 deletions ecal/core/src/readwrite/ecal_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -591,8 +591,7 @@ namespace eCAL

// force to register every second to refresh data clock information
auto curr_time = std::chrono::steady_clock::now();
auto diff_time = curr_time - m_snd_time;
if (diff_time > std::chrono::nanoseconds::zero())
if (std::chrono::duration_cast<std::chrono::milliseconds>(curr_time - m_snd_time) > std::chrono::milliseconds(0))
{
// reset clock and time on first call
if (m_clock_old == 0)
Expand Down

0 comments on commit c296fe1

Please sign in to comment.