summaryrefslogtreecommitdiff
path: root/source/pdf/pdf-stream.c
diff options
context:
space:
mode:
authorSimon Bünzli <zeniko@gmail.com>2013-09-04 14:04:39 +0200
committerRobin Watts <robin.watts@artifex.com>2013-09-10 14:09:01 +0100
commit527afcaa0744472d7ad2ef84ce79ab34a036ad85 (patch)
tree0486bc583d3c98ef1ec673724905b81935b9e9a0 /source/pdf/pdf-stream.c
parentdc45e762170a9b642af588d1c067757ae6a6c683 (diff)
downloadmupdf-527afcaa0744472d7ad2ef84ce79ab34a036ad85.tar.xz
Bug 694567: prevent double-free in pdf_open_raw_filter
If opening a filter in pdf_open_crypt throws, the stream is closed in the used fz_open_* method and thus mustn't be closed again.
Diffstat (limited to 'source/pdf/pdf-stream.c')
-rw-r--r--source/pdf/pdf-stream.c14
1 files changed, 3 insertions, 11 deletions
diff --git a/source/pdf/pdf-stream.c b/source/pdf/pdf-stream.c
index a46cdcc7..88a7559f 100644
--- a/source/pdf/pdf-stream.c
+++ b/source/pdf/pdf-stream.c
@@ -244,17 +244,9 @@ pdf_open_raw_filter(fz_stream *chain, pdf_document *doc, pdf_obj *stmobj, int nu
len = pdf_to_int(pdf_dict_gets(stmobj, "Length"));
chain = fz_open_null(chain, len, offset);
- fz_try(ctx)
- {
- hascrypt = pdf_stream_has_crypt(ctx, stmobj);
- if (doc->crypt && !hascrypt)
- chain = pdf_open_crypt(chain, doc->crypt, orig_num, orig_gen);
- }
- fz_catch(ctx)
- {
- fz_close(chain);
- fz_rethrow(ctx);
- }
+ hascrypt = pdf_stream_has_crypt(ctx, stmobj);
+ if (doc->crypt && !hascrypt)
+ chain = pdf_open_crypt(chain, doc->crypt, orig_num, orig_gen);
return chain;
}