Commit 791faac4da44cc615407e384c0faf333f403adcd

Authored by m-holger
1 parent 5dcf3ba9

Use new read method in QPDF::isLinearized

Showing 1 changed file with 4 additions and 7 deletions
libqpdf/QPDF_linearization.cc
@@ -4,6 +4,7 @@ @@ -4,6 +4,7 @@
4 4
5 #include <qpdf/BitStream.hh> 5 #include <qpdf/BitStream.hh>
6 #include <qpdf/BitWriter.hh> 6 #include <qpdf/BitWriter.hh>
  7 +#include <qpdf/InputSource_private.hh>
7 #include <qpdf/Pl_Buffer.hh> 8 #include <qpdf/Pl_Buffer.hh>
8 #include <qpdf/Pl_Count.hh> 9 #include <qpdf/Pl_Count.hh>
9 #include <qpdf/Pl_Flate.hh> 10 #include <qpdf/Pl_Flate.hh>
@@ -96,14 +97,10 @@ QPDF::isLinearized() @@ -96,14 +97,10 @@ QPDF::isLinearized()
96 97
97 // The PDF spec says the linearization dictionary must be completely contained within the first 98 // The PDF spec says the linearization dictionary must be completely contained within the first
98 // 1024 bytes of the file. Add a byte for a null terminator. 99 // 1024 bytes of the file. Add a byte for a null terminator.
99 - static int const tbuf_size = 1025;  
100 -  
101 - auto b = std::make_unique<char[]>(tbuf_size);  
102 - char* buf = b.get();  
103 - m->file->seek(0, SEEK_SET);  
104 - memset(buf, '\0', tbuf_size);  
105 - m->file->read(buf, tbuf_size - 1); 100 + auto buffer = m->file->read(1024, 0);
106 101
  102 + auto buf = buffer.data();
  103 + auto tbuf_size = buffer.size();
107 int lindict_obj = -1; 104 int lindict_obj = -1;
108 char* p = buf; 105 char* p = buf;
109 while (lindict_obj == -1) { 106 while (lindict_obj == -1) {