From 21e188013cc9535c8e8615d58a4afa3bca65f544 Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Wed, 13 Jul 2016 18:11:45 +0100 Subject: Bug 696892: PDF annotation appearance stream synthesis SEGV The code would SEGV if we were trying to synthesise an appearance stream for an annotation, and the docs pdf resources table had not been initialised. We now intialise the pdf resource tables when we initialise a pdf device. This is the earliest point we know we are going to need them, and covers all cases. --- source/pdf/pdf-device.c | 5 +++++ source/pdf/pdf-xref.c | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'source/pdf') diff --git a/source/pdf/pdf-device.c b/source/pdf/pdf-device.c index 3b974efe..2324dbd7 100644 --- a/source/pdf/pdf-device.c +++ b/source/pdf/pdf-device.c @@ -1127,6 +1127,11 @@ fz_device *pdf_new_pdf_device(fz_context *ctx, pdf_document *doc, const fz_matri if (topctm != &fz_identity) fz_buffer_printf(ctx, buf, "%M cm\n", topctm); + + /* Initialise the resource tables if we have not done so + * already. */ + if (doc->resources == NULL) + pdf_init_resource_tables(ctx, doc); } fz_catch(ctx) { diff --git a/source/pdf/pdf-xref.c b/source/pdf/pdf-xref.c index 01b72d04..576c315d 100644 --- a/source/pdf/pdf-xref.c +++ b/source/pdf/pdf-xref.c @@ -2770,7 +2770,6 @@ pdf_document *pdf_create_document(fz_context *ctx) doc->num_incremental_sections = 0; doc->xref_base = 0; doc->disallow_new_increments = 0; - pdf_init_resource_tables(ctx, doc); pdf_get_populating_xref_entry(ctx, doc, 0); trailer = pdf_new_dict(ctx, doc, 2); pdf_dict_put_drop(ctx, trailer, PDF_NAME_Size, pdf_new_int(ctx, doc, 3)); -- cgit v1.2.3