mirror of
https://github.com/qpdf/qpdf.git
synced 2024-12-22 10:58:58 +00:00
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?
This commit is contained in:
parent
651b51f056
commit
e1cd5891af
@ -1,3 +1,8 @@
|
|||||||
|
2018-08-05 Jay Berkenbilt <ejb@ql.org>
|
||||||
|
|
||||||
|
* Bug fix: infinite loop on progress reporting for very small
|
||||||
|
files. Fixes #230.
|
||||||
|
|
||||||
2018-08-04 Jay Berkenbilt <ejb@ql.org>
|
2018-08-04 Jay Berkenbilt <ejb@ql.org>
|
||||||
|
|
||||||
* Performance fix: optimize page merging operation to avoid
|
* Performance fix: optimize page merging operation to avoid
|
||||||
|
@ -3357,9 +3357,10 @@ QPDFWriter::indicateProgress(bool decrement, bool finished)
|
|||||||
this->m->events_expected)));
|
this->m->events_expected)));
|
||||||
this->m->progress_reporter->reportProgress(percentage);
|
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)
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -925,6 +925,17 @@ $td->runtest("don't overwrite self",
|
|||||||
{$td->REGEXP => "input file and output file are the same.*",
|
{$td->REGEXP => "input file and output file are the same.*",
|
||||||
$td->EXIT_STATUS => 2});
|
$td->EXIT_STATUS => 2});
|
||||||
|
|
||||||
|
show_ntests();
|
||||||
|
# ----------
|
||||||
|
$td->notify("--- Progress reporting ---");
|
||||||
|
$n_tests += 1;
|
||||||
|
|
||||||
|
$td->runtest("progress report on small file",
|
||||||
|
{$td->COMMAND => "qpdf --progress minimal.pdf a.pdf",
|
||||||
|
$td->FILTER => "perl filter-progress.pl"},
|
||||||
|
{$td->FILE => "small-progress.out", $td->EXIT_STATUS => 0},
|
||||||
|
$td->NORMALIZE_NEWLINES);
|
||||||
|
|
||||||
show_ntests();
|
show_ntests();
|
||||||
# ----------
|
# ----------
|
||||||
$td->notify("--- Type checks ---");
|
$td->notify("--- Type checks ---");
|
||||||
|
3
qpdf/qtest/qpdf/small-progress.out
Normal file
3
qpdf/qtest/qpdf/small-progress.out
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
qpdf: a.pdf: write progress: 0%
|
||||||
|
....other write progress....
|
||||||
|
qpdf: a.pdf: write progress: 100%
|
Loading…
Reference in New Issue
Block a user