2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-12-23 11:28:56 +00:00

Use new read method in QPDF::pipeStreamData

This commit is contained in:
m-holger 2024-11-02 13:32:54 +00:00
parent 64a7b9f34a
commit b5be61c516

View File

@ -11,6 +11,7 @@
#include <qpdf/BufferInputSource.hh> #include <qpdf/BufferInputSource.hh>
#include <qpdf/FileInputSource.hh> #include <qpdf/FileInputSource.hh>
#include <qpdf/InputSource_private.hh>
#include <qpdf/OffsetInputSource.hh> #include <qpdf/OffsetInputSource.hh>
#include <qpdf/Pipeline.hh> #include <qpdf/Pipeline.hh>
#include <qpdf/QPDFExc.hh> #include <qpdf/QPDFExc.hh>
@ -22,7 +23,6 @@
#include <qpdf/QPDF_Null.hh> #include <qpdf/QPDF_Null.hh>
#include <qpdf/QPDF_Reserved.hh> #include <qpdf/QPDF_Reserved.hh>
#include <qpdf/QPDF_Stream.hh> #include <qpdf/QPDF_Stream.hh>
#include <qpdf/QPDF_Unresolved.hh>
#include <qpdf/QTC.hh> #include <qpdf/QTC.hh>
#include <qpdf/QUtil.hh> #include <qpdf/QUtil.hh>
@ -980,12 +980,11 @@ QPDF::pipeStreamData(
bool attempted_finish = false; bool attempted_finish = false;
try { try {
file->seek(offset, SEEK_SET); auto buf = file->read(length, offset);
auto buf = std::make_unique<char[]>(length); if (buf.size() != length) {
if (auto read = file->read(buf.get(), length); read != length) { throw damagedPDF(*file, "", offset + toO(buf.size()), "unexpected EOF reading stream data");
throw damagedPDF(*file, "", offset + toO(read), "unexpected EOF reading stream data");
} }
pipeline->write(buf.get(), length); pipeline->write(buf.data(), length);
attempted_finish = true; attempted_finish = true;
pipeline->finish(); pipeline->finish();
return true; return true;