diff options
Diffstat (limited to 'pdf/pdf_stream.c')
-rw-r--r-- | pdf/pdf_stream.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/pdf/pdf_stream.c b/pdf/pdf_stream.c index 3db8eb1c..a01bab55 100644 --- a/pdf/pdf_stream.c +++ b/pdf/pdf_stream.c @@ -225,6 +225,7 @@ pdf_open_filter(fz_stream *chain, pdf_document *xref, fz_obj *stmobj, int num, i else if (fz_array_len(filters) > 0) chain = build_filter_chain(chain, xref, filters, params, num, gen); + fz_lock_stream(chain); return chain; } @@ -276,6 +277,7 @@ pdf_open_raw_stream(pdf_document *xref, int num, int gen) fz_throw(xref->ctx, "object is not a stream"); stm = pdf_open_raw_filter(xref->file, xref, x->obj, num, gen); + fz_lock_stream(stm); fz_seek(xref->file, x->stm_ofs, 0); return stm; } @@ -316,6 +318,7 @@ pdf_open_stream_with_offset(pdf_document *xref, int num, int gen, fz_obj *dict, fz_throw(xref->ctx, "object is not a stream"); stm = pdf_open_filter(xref->file, xref, dict, num, gen); + fz_lock_stream(stm); fz_seek(xref->file, stm_ofs, 0); return stm; } @@ -378,9 +381,6 @@ pdf_load_stream(pdf_document *xref, int num, int gen) fz_var(buf); - stm = pdf_open_stream(xref, num, gen); - /* RJW: "cannot open stream (%d %d R)", num, gen */ - dict = pdf_load_object(xref, num, gen); /* RJW: "cannot load stream dictionary (%d %d R)", num, gen */ @@ -393,16 +393,21 @@ pdf_load_stream(pdf_document *xref, int num, int gen) fz_drop_obj(dict); + stm = pdf_open_stream(xref, num, gen); + /* RJW: "cannot open stream (%d %d R)", num, gen */ + fz_try(ctx) { buf = fz_read_all(stm, len); } - fz_catch(ctx) + fz_always(ctx) { fz_close(stm); + } + fz_catch(ctx) + { fz_throw(ctx, "cannot read raw stream (%d %d R)", num, gen); } - fz_close(stm); return buf; } |