Skip to content

Commit

Permalink
dont divide by 0
Browse files Browse the repository at this point in the history
  • Loading branch information
moonshadow565 committed Oct 3, 2022
1 parent 4783a0f commit 1b858a5
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/rlib/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,13 @@ rlib::progress_bar::progress_bar(char const* banner,
std::uint32_t index,
std::uint64_t done,
std::uint64_t total) noexcept
: banner_(banner), disabled_(disabled), index_(index), done_(done), total_(total), percent_(done_ * 100 / total_) {
: banner_(banner),
disabled_(disabled),
index_(index),
done_(done),
total_(std::max(total, std::uint64_t{1})),
percent_(done_ * 100 / total_)
{
this->render();
}

Expand Down

0 comments on commit 1b858a5

Please sign in to comment.