diff options
-rw-r--r-- | source/html/html-doc.c | 13 | ||||
-rw-r--r-- | source/pdf/pdf-stream.c | 8 |
2 files changed, 16 insertions, 5 deletions
diff --git a/source/html/html-doc.c b/source/html/html-doc.c index f14ddc35..733dd620 100644 --- a/source/html/html-doc.c +++ b/source/html/html-doc.c @@ -129,9 +129,16 @@ htdoc_open_document_with_stream(fz_context *ctx, fz_stream *file) doc->set = fz_new_html_font_set(ctx); buf = fz_read_all(ctx, file, 0); - fz_write_buffer_byte(ctx, buf, 0); - doc->box = fz_parse_html(ctx, doc->set, doc->zip, ".", buf, fz_user_css(ctx)); - fz_drop_buffer(ctx, buf); + + fz_try(ctx) + { + fz_write_buffer_byte(ctx, buf, 0); + doc->box = fz_parse_html(ctx, doc->set, doc->zip, ".", buf, fz_user_css(ctx)); + } + fz_always(ctx) + fz_drop_buffer(ctx, buf); + fz_catch(ctx) + fz_rethrow(ctx); return (fz_document*)doc; } diff --git a/source/pdf/pdf-stream.c b/source/pdf/pdf-stream.c index 9ff136b2..39f85b0b 100644 --- a/source/pdf/pdf-stream.c +++ b/source/pdf/pdf-stream.c @@ -458,9 +458,13 @@ pdf_load_raw_stream_number(fz_context *ctx, pdf_document *doc, int num) stm = pdf_open_raw_stream_number(ctx, doc, num); - buf = fz_read_all(ctx, stm, len); + fz_try(ctx) + buf = fz_read_all(ctx, stm, len); + fz_always(ctx) + fz_drop_stream(ctx, stm); + fz_catch(ctx) + fz_rethrow(ctx); - fz_drop_stream(ctx, stm); return buf; } |