Skip to content

Commit 1b858a5

Browse files
author
moonshadow565
committed
dont divide by 0
1 parent 4783a0f commit 1b858a5

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/rlib/common.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,13 @@ rlib::progress_bar::progress_bar(char const* banner,
3737
std::uint32_t index,
3838
std::uint64_t done,
3939
std::uint64_t total) noexcept
40-
: banner_(banner), disabled_(disabled), index_(index), done_(done), total_(total), percent_(done_ * 100 / total_) {
40+
: banner_(banner),
41+
disabled_(disabled),
42+
index_(index),
43+
done_(done),
44+
total_(std::max(total, std::uint64_t{1})),
45+
percent_(done_ * 100 / total_)
46+
{
4147
this->render();
4248
}
4349

0 commit comments

Comments
 (0)