diff options
author | Jay Berkenbilt <ejb@ql.org> | 2012-06-20 17:20:57 +0200 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2012-06-20 21:20:26 +0200 |
commit | 5d4cad9c02e9d4f31477fed0e3b20b35c83936f8 (patch) | |
tree | 38768f5e4a797e09de304b1e184021f5b280da29 /libqpdf/Pl_Flate.cc | |
parent | 24e2b2b76f1f0051f240c8371b2352c4cde85bf9 (diff) | |
download | qpdf-5d4cad9c02e9d4f31477fed0e3b20b35c83936f8.tar.zst |
ABI change: fix use of off_t, size_t, and integer types
Significantly improve the code's use of off_t for file offsets, size_t
for memory sizes, and integer types in cases where there has to be
compatibility with external interfaces. Rework sections of the code
that would have prevented qpdf from working on files larger than 2 (or
maybe 4) GB in size.
Diffstat (limited to 'libqpdf/Pl_Flate.cc')
-rw-r--r-- | libqpdf/Pl_Flate.cc | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/libqpdf/Pl_Flate.cc b/libqpdf/Pl_Flate.cc index d166e9ab..30616707 100644 --- a/libqpdf/Pl_Flate.cc +++ b/libqpdf/Pl_Flate.cc @@ -40,7 +40,7 @@ Pl_Flate::~Pl_Flate() } void -Pl_Flate::write(unsigned char* data, int len) +Pl_Flate::write(unsigned char* data, size_t len) { if (this->outbuf == 0) { @@ -48,7 +48,19 @@ Pl_Flate::write(unsigned char* data, int len) this->identifier + ": Pl_Flate: write() called after finish() called"); } - handleData(data, len, Z_NO_FLUSH); + + // Write in chunks in case len is too big to fit in an int. + // Assume int is at least 32 bits. + static size_t const max_bytes = 1 << 30; + size_t bytes_left = len; + unsigned char* buf = data; + while (bytes_left > 0) + { + size_t bytes = (bytes_left >= max_bytes ? max_bytes : bytes_left); + handleData(buf, (int)bytes, Z_NO_FLUSH); + bytes_left -= bytes; + buf += bytes; + } } void |