From e1cd5891af199dc6d926a1792c9add182b39fc56 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Sun, 5 Aug 2018 15:42:01 -0400 Subject: Fix infinite loop on small files with progress reporting (fixes #230) Turns out you can keep adding zero to a number over and over again and it just doesn't get any bigger. Who would have known? --- libqpdf/QPDFWriter.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'libqpdf/QPDFWriter.cc') diff --git a/libqpdf/QPDFWriter.cc b/libqpdf/QPDFWriter.cc index 447b6627..30ba6f1f 100644 --- a/libqpdf/QPDFWriter.cc +++ b/libqpdf/QPDFWriter.cc @@ -3357,9 +3357,10 @@ QPDFWriter::indicateProgress(bool decrement, bool finished) this->m->events_expected))); this->m->progress_reporter->reportProgress(percentage); } + int increment = std::max(1, (this->m->events_expected / 100)); while (this->m->events_seen >= this->m->next_progress_report) { - this->m->next_progress_report += (this->m->events_expected / 100); + this->m->next_progress_report += increment; } } -- cgit v1.2.3-54-g00ecf