Commit 98014ec98a0175d6853ac5fe0ee420913fb78d16

Authored by Jay Berkenbilt
1 parent b075de73

Fix error with stream recovery (fixes #1042)

Showing 2 changed files with 9 additions and 1 deletions
ChangeLog
  1 +2023-10-07 Jay Berkenbilt <ejb@ql.org>
  2 +
  3 + * Bug fix: when piping stream data, don't call finish on failure
  4 + if the failure was caused by a previous call to finish. Fixes
  5 + #1042.
  6 +
1 7 2023-09-05 Jay Berkenbilt <ejb@ql.org>
2 8  
3 9 * 11.6.1: release
... ...
libqpdf/QPDF.cc
... ... @@ -2418,6 +2418,7 @@ QPDF::pipeStreamData(
2418 2418 decryptStream(encp, file, qpdf_for_warning, pipeline, og, stream_dict, to_delete);
2419 2419 }
2420 2420  
  2421 + bool attempted_finish = false;
2421 2422 bool success = false;
2422 2423 try {
2423 2424 file->seek(offset, SEEK_SET);
... ... @@ -2432,6 +2433,7 @@ QPDF::pipeStreamData(
2432 2433 length -= len;
2433 2434 pipeline->write(buf, len);
2434 2435 }
  2436 + attempted_finish = true;
2435 2437 pipeline->finish();
2436 2438 success = true;
2437 2439 } catch (QPDFExc& e) {
... ... @@ -2461,7 +2463,7 @@ QPDF::pipeStreamData(
2461 2463 }
2462 2464 }
2463 2465 }
2464   - if (!success) {
  2466 + if (!attempted_finish) {
2465 2467 try {
2466 2468 pipeline->finish();
2467 2469 } catch (std::exception&) {
... ...