diff --git a/include/qpdf/Pl_Buffer.hh b/include/qpdf/Pl_Buffer.hh index 39ef0746..5030e10e 100644 --- a/include/qpdf/Pl_Buffer.hh +++ b/include/qpdf/Pl_Buffer.hh @@ -33,6 +33,7 @@ #include // unused -- remove in qpdf 12 (see #785) #include +#include class QPDF_DLL_CLASS Pl_Buffer: public Pipeline { @@ -77,7 +78,7 @@ class QPDF_DLL_CLASS Pl_Buffer: public Pipeline Members(Members const&) = delete; bool ready{true}; - std::basic_string data; + std::vector data; }; std::shared_ptr m; diff --git a/libqpdf/Pl_Buffer.cc b/libqpdf/Pl_Buffer.cc index b10cf544..766c04b5 100644 --- a/libqpdf/Pl_Buffer.cc +++ b/libqpdf/Pl_Buffer.cc @@ -19,7 +19,7 @@ Pl_Buffer::~Pl_Buffer() // NOLINT (modernize-use-equals-default) void Pl_Buffer::write(unsigned char const* buf, size_t len) { - m->data.append(buf, len); + m->data.insert(m->data.end(), buf, buf + len); m->ready = false; if (getNext(true)) { @@ -43,7 +43,7 @@ Pl_Buffer::getBuffer() throw std::logic_error("Pl_Buffer::getBuffer() called when not ready"); } - auto size = m->data.length(); + auto size = m->data.size(); auto* b = new Buffer(size); if (size > 0) { unsigned char* p = b->getBuffer(); @@ -65,7 +65,7 @@ Pl_Buffer::getMallocBuffer(unsigned char** buf, size_t* len) if (!m->ready) { throw std::logic_error("Pl_Buffer::getMallocBuffer() called when not ready"); } - auto size = m->data.length(); + auto size = m->data.size(); *len = size; if (size > 0) { *buf = reinterpret_cast(malloc(size));