[mupdf] Ensure document is always freed (#1094)

This commit is contained in:
Jonathan Rudenberg 2018-01-19 14:05:50 -05:00 committed by Abhishek Arya
parent 6eac0c48a5
commit 3b6b482b52
1 changed files with 6 additions and 3 deletions

View File

@ -26,17 +26,20 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
fz_stream *stream = fz_open_memory(ctx, data, size);
fz_matrix ctm;
fz_pixmap *pix;
fz_pixmap *pix = NULL;
fz_document *doc = NULL;
fz_try(ctx) {
fz_document *doc = fz_open_document_with_stream(ctx, "pdf", stream);
doc = fz_open_document_with_stream(ctx, "pdf", stream);
for (int i = 0; i < fz_count_pages(ctx, doc); i++) {
pix = fz_new_pixmap_from_page_number(ctx, doc, i, &ctm, fz_device_rgb(ctx), 0);
fz_drop_pixmap(ctx, pix);
}
fz_drop_document(ctx, doc);
}
fz_catch(ctx) {}
if (doc) {
fz_drop_document(ctx, doc);
}
fz_drop_stream(ctx, stream);
fz_drop_context(ctx);