diff --git a/ChangeLog b/ChangeLog index 56eebe2b..1e9f8154 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2023-10-07 Jay Berkenbilt + + * Bug fix: when piping stream data, don't call finish on failure + if the failure was caused by a previous call to finish. Fixes + #1042. + 2023-09-05 Jay Berkenbilt * 11.6.1: release diff --git a/libqpdf/QPDF.cc b/libqpdf/QPDF.cc index bd591a51..473cf5f0 100644 --- a/libqpdf/QPDF.cc +++ b/libqpdf/QPDF.cc @@ -2418,6 +2418,7 @@ QPDF::pipeStreamData( decryptStream(encp, file, qpdf_for_warning, pipeline, og, stream_dict, to_delete); } + bool attempted_finish = false; bool success = false; try { file->seek(offset, SEEK_SET); @@ -2432,6 +2433,7 @@ QPDF::pipeStreamData( length -= len; pipeline->write(buf, len); } + attempted_finish = true; pipeline->finish(); success = true; } catch (QPDFExc& e) { @@ -2461,7 +2463,7 @@ QPDF::pipeStreamData( } } } - if (!success) { + if (!attempted_finish) { try { pipeline->finish(); } catch (std::exception&) {