From 7cc1e08de95015b3dd460029a9e746cb6eeaf60f Mon Sep 17 00:00:00 2001 From: m-holger Date: Sun, 23 Mar 2025 13:33:17 +0000 Subject: [PATCH] In QPDFWriter::writeLinearized use Pl_String instead of Pl_Buffer --- libqpdf/QPDFWriter.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libqpdf/QPDFWriter.cc b/libqpdf/QPDFWriter.cc index 2cbf4ad..54b00b3 100644 --- a/libqpdf/QPDFWriter.cc +++ b/libqpdf/QPDFWriter.cc @@ -2684,14 +2684,14 @@ QPDFWriter::writeLinearized() } qpdf_offset_t hint_length = 0; - std::shared_ptr hint_buffer; + std::string hint_buffer; // Write file in two passes. Part numbers refer to PDF spec 1.4. FILE* lin_pass1_file = nullptr; auto pp_pass1 = std::make_shared(this); auto pp_md5 = std::make_shared(this); - for (int pass = 1; pass <= 2; ++pass) { + for (int pass: {1, 2}) { if (pass == 1) { if (!m->lin_pass1_filename.empty()) { lin_pass1_file = QUtil::safe_fopen(m->lin_pass1_filename.c_str(), "wb"); @@ -2828,7 +2828,7 @@ QPDFWriter::writeLinearized() m->new_obj[hint_id].xref = QPDFXRefEntry(m->pipeline->getCount()); } else { // Part 5: hint stream - writeBuffer(hint_buffer); + writeString(hint_buffer); } } if (cur_object.getObjectID() == part6_end_marker) { @@ -2902,12 +2902,12 @@ QPDFWriter::writeLinearized() // Write hint stream to a buffer { - pushPipeline(new Pl_Buffer("hint buffer")); - PipelinePopper pp_hint(this, &hint_buffer); + pushPipeline(new Pl_String("hint buffer", nullptr, hint_buffer)); + PipelinePopper pp_hint(this); activatePipelineStack(pp_hint); writeHintStream(hint_id); } - hint_length = QIntC::to_offset(hint_buffer->getSize()); + hint_length = QIntC::to_offset(hint_buffer.size()); // Restore hint offset m->new_obj[hint_id].xref = QPDFXRefEntry(hint_offset1); -- libgit2 0.21.4