Skip to content

Commit 07a0cdf

Browse files
committed
Fix crash in LongJobHelper::real_check
If the LongJobHelper::real_check method was called with the `progress` parameter equal to `mMaximum`, a division by zero and a program crash occurred.
1 parent a11848e commit 07a0cdf

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

gcodeshared/ui/longjobhelper.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ int LongJobHelper::real_check(int progress)
6464
{
6565
mTotalTime = time_ms();
6666

67-
if (!mIsLongJob) {
68-
int remaining = mTotalTime * mMaximum / (mMaximum - progress);
67+
if (!mIsLongJob && progress > 0) {
68+
int remaining = mTotalTime * (mMaximum - progress) / progress;
6969

7070
if (mTotalTime > mDeadLine || remaining > mDeadLine) {
7171
mIsLongJob = true;

0 commit comments

Comments
 (0)