Skip to content

Commit

Permalink
Fix Coverity divide-by-zero warning
Browse files Browse the repository at this point in the history
Closes CID 1380221

Instead of assert() throw an exception explaining what went wrong.
  • Loading branch information
GregoryLundberg authored and jyrkive committed Sep 17, 2017
1 parent c6f523f commit 7c3d789
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/display.cpp
Expand Up @@ -350,7 +350,11 @@ void display::init_flags_for_side_internal(size_t n, const std::string& side_col
animated<image::locator>& f = flags_[n];

f = temp_anim;
assert(f.get_end_time() != 0);
if (f.get_end_time() <= 0) {
std::stringstream msg;
msg << "Invalid animation duration (<= 0) found when constructing flag for side " << n;
throw std::domain_error(msg.str());
}
f.start_animation(rand() % f.get_end_time(), true);
}

Expand Down

0 comments on commit 7c3d789

Please sign in to comment.