From 98014ec98a0175d6853ac5fe0ee420913fb78d16 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Sat, 7 Oct 2023 13:29:10 -0400 Subject: Fix error with stream recovery (fixes #1042) --- libqpdf/QPDF.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'libqpdf/QPDF.cc') 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&) { -- cgit v1.2.3-54-g00ecf