Fix Coverity divide-by-zero warning

Closes CID 1380221

Instead of assert() throw an exception explaining what went wrong.
This commit is contained in:
Gregory A Lundberg 2017-09-11 05:45:24 -05:00 committed by Jyrki Vesterinen
parent c6f523f8cd
commit 7c3d789514

View file

@ -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);
}