summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2015-04-03 16:30:19 +0100
committerRobin Watts <robin.watts@artifex.com>2015-04-03 16:37:18 +0100
commitd4ae4095cc1121b9a7a5ca9a444adaa08906e846 (patch)
treee75ad74124830f429df2a8200ce37be66f75c2ea /include
parent57121ca1cc81b502f3a4a0f79759404d0fb0d846 (diff)
downloadmupdf-d4ae4095cc1121b9a7a5ca9a444adaa08906e846.tar.xz
Bug 694713: Avoid assert when using pdf_page_write
When writing a pdf page, we pass page->contents to pdf_new_pdf_device. This object is assumed to be a dictionary (stream) that can be updated with the Length and stream contents once the page writing process has completed. When we are rewriting a pdf page however, this can go wrong; page->contents can be an array of objects. Not only this, in general it would be possible for several pages to share the same page contents (or maybe some of the elements of a page contents array). Updating one page should not update the others. We therefore update pdf_page_write to always create a new page->contents object and use that. Thanks to Michael Cadilhac for spotting the basic problem here.
Diffstat (limited to 'include')
-rw-r--r--include/mupdf/pdf/output-pdf.h4
-rw-r--r--include/mupdf/pdf/page.h2
2 files changed, 6 insertions, 0 deletions
diff --git a/include/mupdf/pdf/output-pdf.h b/include/mupdf/pdf/output-pdf.h
index 1e783201..617d32fc 100644
--- a/include/mupdf/pdf/output-pdf.h
+++ b/include/mupdf/pdf/output-pdf.h
@@ -5,6 +5,10 @@
pdf_new_pdf_device: Create a pdf device. Rendering to the device creates
new pdf content. WARNING: this device is work in progress. It doesn't
currently support all rendering cases.
+
+ Note that contents must be a stream (dictionary) to be updated (or
+ a reference to a stream). Callers should take care to ensure that it
+ is not an array, and that is it not shared with other objects/pages.
*/
fz_device *pdf_new_pdf_device(fz_context *ctx, pdf_document *doc, pdf_obj *contents, pdf_obj *resources, const fz_matrix *ctm, fz_buffer *buf);
diff --git a/include/mupdf/pdf/page.h b/include/mupdf/pdf/page.h
index 2a323ddb..79b7659e 100644
--- a/include/mupdf/pdf/page.h
+++ b/include/mupdf/pdf/page.h
@@ -17,6 +17,8 @@ pdf_obj *pdf_lookup_page_obj(fz_context *ctx, pdf_document *doc, int needle);
*/
pdf_page *pdf_load_page(fz_context *ctx, pdf_document *doc, int number);
+void pdf_drop_page(fz_context *ctx, pdf_page *page);
+
fz_link *pdf_load_links(fz_context *ctx, pdf_page *page);
/*