diff options
author | Ken Sharp <ken.sharp@artifex.com> | 2022-03-10 14:35:46 +0000 |
---|---|---|
committer | Chris Liddell <chris.liddell@artifex.com> | 2022-03-14 10:07:35 +0000 |
commit | 02352ab7753ba74bbfdfa31227932a7809465ef4 (patch) | |
tree | 9b5d0d93979f7d56f27ff4457f21a6ab79ea7f53 | |
parent | 388cd8d0e1c2494281a080bba7af743575280c4e (diff) | |
download | ghostpdl-02352ab7753ba74bbfdfa31227932a7809465ef4.tar.gz |
Fix code to detect size of uncompressed stream data
When converting a stream to a buffer in memory, we need to know the size
of the uncompressed stream data, in order to allocate a buffer.
Chris improved the speed of this, but it turns out that the insane
stream code doesn't necessarily update the file pointer when we discard
a buffer, if the stream is just the native file.
So instead of using sreset(), use sbufskip(). Rather than simply
setting the buffer pointer back to the start, this sets it to the end,
as if we had actually consumed all the data. That then means
s_process_read_buf() will call stream_compact() and that will update
the stream 'position' member. Previously that wasn't happening, even
though we were reading more data from the file, which caused
considerable confusion!
-rw-r--r-- | pdf/pdf_file.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/pdf/pdf_file.c b/pdf/pdf_file.c index 1306f125b..5698866e1 100644 --- a/pdf/pdf_file.c +++ b/pdf/pdf_file.c @@ -1571,7 +1571,7 @@ pdfi_stream_to_buffer(pdf_context *ctx, pdf_stream *stream_obj, byte **buf, int6 goto exit; } while (seofp(stream->s) != true && serrorp(stream->s) != true) { - sreset(stream->s); + (void)sbufskip(stream->s, sbufavailable(stream->s)); s_process_read_buf(stream->s); buflen += sbufavailable(stream->s); } |