summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2016-03-30 16:39:36 +0100
committerRobin Watts <robin.watts@artifex.com>2016-03-30 18:18:00 +0100
commit9ccdd63f008d865b87e9f55b24a0276670844786 (patch)
tree64f2ccb5a33c08b0b13e89b2a70c5e5f491ea229 /source
parentf863e1ad7ecf0e67db5906f9562682a2e7ae7b5f (diff)
downloadmupdf-9ccdd63f008d865b87e9f55b24a0276670844786.tar.xz
Use fz_new_document for pdf and html docs.
In particular for html docs we were getting the refcount wrong, causing us to leak on closedown.
Diffstat (limited to 'source')
-rw-r--r--source/html/html-doc.c2
-rw-r--r--source/pdf/pdf-xref.c3
2 files changed, 2 insertions, 3 deletions
diff --git a/source/html/html-doc.c b/source/html/html-doc.c
index 6ad5c3e8..23f1195b 100644
--- a/source/html/html-doc.c
+++ b/source/html/html-doc.c
@@ -144,7 +144,7 @@ htdoc_open_document(fz_context *ctx, const char *filename)
fz_dirname(dirname, filename, sizeof dirname);
- doc = fz_malloc_struct(ctx, html_document);
+ doc = fz_new_document(ctx, sizeof *doc);
doc->super.close = htdoc_close_document;
doc->super.layout = htdoc_layout;
doc->super.count_pages = htdoc_count_pages;
diff --git a/source/pdf/pdf-xref.c b/source/pdf/pdf-xref.c
index f8711d3c..6eca8a74 100644
--- a/source/pdf/pdf-xref.c
+++ b/source/pdf/pdf-xref.c
@@ -2325,9 +2325,8 @@ pdf_page_presentation(fz_context *ctx, pdf_page *page, float *duration)
static pdf_document *
pdf_new_document(fz_context *ctx, fz_stream *file)
{
- pdf_document *doc = fz_malloc_struct(ctx, pdf_document);
+ pdf_document *doc = fz_new_document(ctx, sizeof *doc);
- doc->super.refs = 1;
doc->super.close = (fz_document_close_fn *)pdf_close_document;
doc->super.needs_password = (fz_document_needs_password_fn *)pdf_needs_password;
doc->super.authenticate_password = (fz_document_authenticate_password_fn *)pdf_authenticate_password;