Commit 5dcf3ba9e3ee9cc5fd0841b81855e6c17ffc9d8b

Authored by m-holger
1 parent 24cf3bca

Use new read method in QPDF::pipeStreamData

Showing 1 changed file with 5 additions and 5 deletions
libqpdf/QPDF.cc
... ... @@ -13,6 +13,7 @@
13 13  
14 14 #include <qpdf/BufferInputSource.hh>
15 15 #include <qpdf/FileInputSource.hh>
  16 +#include <qpdf/InputSource_private.hh>
16 17 #include <qpdf/OffsetInputSource.hh>
17 18 #include <qpdf/Pipeline.hh>
18 19 #include <qpdf/QPDFExc.hh>
... ... @@ -2761,12 +2762,11 @@ QPDF::pipeStreamData(
2761 2762  
2762 2763 bool attempted_finish = false;
2763 2764 try {
2764   - file->seek(offset, SEEK_SET);
2765   - auto buf = std::make_unique<char[]>(length);
2766   - if (auto read = file->read(buf.get(), length); read != length) {
2767   - throw damagedPDF(*file, "", offset + toO(read), "unexpected EOF reading stream data");
  2765 + auto buf = file->read(length, offset);
  2766 + if (buf.size() != length) {
  2767 + throw damagedPDF(*file, "", offset + toO(buf.size()), "unexpected EOF reading stream data");
2768 2768 }
2769   - pipeline->write(buf.get(), length);
  2769 + pipeline->write(buf.data(), length);
2770 2770 attempted_finish = true;
2771 2771 pipeline->finish();
2772 2772 return true;
... ...