From 28d9c75ed780414a7ae71cab88cc86536444b255 Mon Sep 17 00:00:00 2001 From: Sebastian Rasmussen Date: Tue, 11 Oct 2016 19:06:22 +0800 Subject: Free document in fz_drop_document(), not in subclassing documents. --- source/cbz/mucbz.c | 1 - source/cbz/muimg.c | 1 - source/cbz/mutiff.c | 1 - source/fitz/document.c | 3 +++ source/gprf/gprf-doc.c | 2 -- source/html/epub-doc.c | 1 - source/html/html-doc.c | 1 - source/pdf/pdf-xref.c | 2 -- source/svg/svg-doc.c | 1 - source/xps/xps-zip.c | 1 - 10 files changed, 3 insertions(+), 11 deletions(-) diff --git a/source/cbz/mucbz.c b/source/cbz/mucbz.c index 8e281c64..23143fac 100644 --- a/source/cbz/mucbz.c +++ b/source/cbz/mucbz.c @@ -105,7 +105,6 @@ cbz_drop_document(fz_context *ctx, cbz_document *doc) { fz_drop_archive(ctx, doc->arch); fz_free(ctx, (char **)doc->page); - fz_free(ctx, doc); } static int diff --git a/source/cbz/muimg.c b/source/cbz/muimg.c index 1f181cab..a02731c6 100644 --- a/source/cbz/muimg.c +++ b/source/cbz/muimg.c @@ -21,7 +21,6 @@ static void img_drop_document(fz_context *ctx, img_document *doc) { fz_drop_image(ctx, doc->image); - fz_free(ctx, doc); } static int diff --git a/source/cbz/mutiff.c b/source/cbz/mutiff.c index 7423c3c1..fb88e11b 100644 --- a/source/cbz/mutiff.c +++ b/source/cbz/mutiff.c @@ -111,7 +111,6 @@ static void tiff_drop_document(fz_context *ctx, tiff_document *doc) { fz_drop_buffer(ctx, doc->buffer); - fz_free(ctx, doc); } static tiff_document * diff --git a/source/fitz/document.c b/source/fitz/document.c index 4c02f1c4..d783bc70 100644 --- a/source/fitz/document.c +++ b/source/fitz/document.c @@ -163,8 +163,11 @@ void fz_drop_document(fz_context *ctx, fz_document *doc) { if (fz_drop_imp(ctx, doc, &doc->refs)) + { if (doc->drop_document) doc->drop_document(ctx, doc); + fz_free(ctx, doc); + } } static void diff --git a/source/gprf/gprf-doc.c b/source/gprf/gprf-doc.c index f74454e5..e269229e 100644 --- a/source/gprf/gprf-doc.c +++ b/source/gprf/gprf-doc.c @@ -908,8 +908,6 @@ gprf_close_document(fz_context *ctx, fz_document *doc_) fz_free(ctx, doc->gprf_filename); fz_free(ctx, doc->print_profile); fz_free(ctx, doc->display_profile); - - fz_free(ctx, doc); } static int diff --git a/source/html/epub-doc.c b/source/html/epub-doc.c index fbcc1a86..efa43075 100644 --- a/source/html/epub-doc.c +++ b/source/html/epub-doc.c @@ -219,7 +219,6 @@ epub_drop_document(fz_context *ctx, fz_document *doc_) fz_drop_outline(ctx, doc->outline); fz_free(ctx, doc->dc_title); fz_free(ctx, doc->dc_creator); - fz_free(ctx, doc); } static const char * diff --git a/source/html/html-doc.c b/source/html/html-doc.c index fdd087dc..90de5c82 100644 --- a/source/html/html-doc.c +++ b/source/html/html-doc.c @@ -29,7 +29,6 @@ htdoc_drop_document(fz_context *ctx, fz_document *doc_) fz_drop_archive(ctx, doc->zip); fz_drop_html(ctx, doc->box); fz_drop_html_font_set(ctx, doc->set); - fz_free(ctx, doc); } static int diff --git a/source/pdf/pdf-xref.c b/source/pdf/pdf-xref.c index 87616f40..a1e2f88d 100644 --- a/source/pdf/pdf-xref.c +++ b/source/pdf/pdf-xref.c @@ -1652,8 +1652,6 @@ pdf_drop_document_imp(fz_context *ctx, pdf_document *doc) pdf_drop_obj(ctx, doc->orphans[i]); } fz_free(ctx, doc->orphans); - - fz_free(ctx, doc); } fz_always(ctx) { diff --git a/source/svg/svg-doc.c b/source/svg/svg-doc.c index bd0b2dd1..fa2b3d19 100644 --- a/source/svg/svg-doc.c +++ b/source/svg/svg-doc.c @@ -14,7 +14,6 @@ svg_drop_document(fz_context *ctx, fz_document *doc_) svg_document *doc = (svg_document*)doc_; fz_drop_tree(ctx, doc->idmap, NULL); fz_drop_xml(ctx, doc->root); - fz_free(ctx, doc); } static int diff --git a/source/xps/xps-zip.c b/source/xps/xps-zip.c index fbcb6d44..1d8f5bc8 100644 --- a/source/xps/xps-zip.c +++ b/source/xps/xps-zip.c @@ -217,7 +217,6 @@ xps_drop_document(fz_context *ctx, xps_document *doc) xps_drop_page_list(ctx, doc); fz_free(ctx, doc->start_part); - fz_free(ctx, doc); } static int -- cgit v1.2.3