diff --git a/include/qpdf/QPDFWriter.hh b/include/qpdf/QPDFWriter.hh index a9d60672..56771e18 100644 --- a/include/qpdf/QPDFWriter.hh +++ b/include/qpdf/QPDFWriter.hh @@ -751,7 +751,8 @@ class QPDFWriter std::string cur_data_key; std::list> to_delete; Pl_Count* pipeline; - std::list object_queue; + std::vector object_queue; + size_t object_queue_front{0}; std::map obj_renumber; std::map xref; std::map lengths; diff --git a/libqpdf/QPDFWriter.cc b/libqpdf/QPDFWriter.cc index e1225c34..383a6886 100644 --- a/libqpdf/QPDFWriter.cc +++ b/libqpdf/QPDFWriter.cc @@ -3363,9 +3363,9 @@ QPDFWriter::writeStandard() } // Now start walking queue, outputting each object. - while (this->m->object_queue.size()) { - QPDFObjectHandle cur_object = this->m->object_queue.front(); - this->m->object_queue.pop_front(); + while (m->object_queue_front < m->object_queue.size()) { + QPDFObjectHandle cur_object = m->object_queue.at(m->object_queue_front); + ++m->object_queue_front; writeObject(cur_object); }