summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKen Sharp <Ken.Sharp@artifex.com>2024-03-03 11:22:13 +0000
committerChris Liddell <chris.liddell@artifex.com>2024-03-04 09:40:17 +0000
commited3594bb59bb3c2bfa2c701d6cb24ecac96815a8 (patch)
tree71235337c68b9d22fa4ea694e6fd90e6e3ee4301
parent30c10510b281335dcc39e3b2e0b811ca6892e4ef (diff)
PDF interpreter - fix a memory leak
This was accidentally introduced when adding a SubFileDecode to the stream_to_buffer() function. Because we create a new stream with the SubFileDecode, separately from the filter chain of the actual underlying stream, we need to explicitly close that stream.
-rw-r--r--pdf/pdf_file.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/pdf/pdf_file.c b/pdf/pdf_file.c
index 1d4963ffc..84a4a760f 100644
--- a/pdf/pdf_file.c
+++ b/pdf/pdf_file.c
@@ -1754,6 +1754,8 @@ retry:
goto exit;
read = sfread(Buffer, 1, buflen, stream->s);
pdfi_close_file(ctx, stream);
+ /* Because we opened the SubFileDecode separately to the filter chain, we need to close it separately too */
+ pdfi_close_file(ctx, SubFileStream);
if (read == ERRC) {
/* Error reading the expected number of bytes. If we already calculated the number of
* bytes in the loop above, then ignore the error and carry on. If, however, we were