summaryrefslogtreecommitdiff
path: root/source/pdf
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2016-12-23 14:24:29 +0100
committerSebastian Rasmussen <sebras@gmail.com>2016-12-23 15:01:22 +0100
commit9d7e833e33e37e0be20b82a9153d18f5148e94d5 (patch)
treee04e21e84585ed6a89c114915075b2e43fc9cfda /source/pdf
parentd06a844f3e9e38f6cc284f6d3d3a380b814447b4 (diff)
downloadmupdf-9d7e833e33e37e0be20b82a9153d18f5148e94d5.tar.xz
Cope with NULL resource and concents arguments to pdf_add_page.
Diffstat (limited to 'source/pdf')
-rw-r--r--source/pdf/pdf-page.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/source/pdf/pdf-page.c b/source/pdf/pdf-page.c
index 64b30cf6..1b20b091 100644
--- a/source/pdf/pdf-page.c
+++ b/source/pdf/pdf-page.c
@@ -683,8 +683,16 @@ pdf_add_page(fz_context *ctx, pdf_document *doc, const fz_rect *mediabox, int ro
pdf_dict_put_drop(ctx, page_obj, PDF_NAME_Type, PDF_NAME_Page);
pdf_dict_put_drop(ctx, page_obj, PDF_NAME_MediaBox, pdf_new_rect(ctx, doc, mediabox));
pdf_dict_put_drop(ctx, page_obj, PDF_NAME_Rotate, pdf_new_int(ctx, doc, rotate));
- pdf_dict_put_drop(ctx, page_obj, PDF_NAME_Resources, pdf_add_object(ctx, doc, resources));
- pdf_dict_put_drop(ctx, page_obj, PDF_NAME_Contents, pdf_add_stream(ctx, doc, contents, NULL, 0));
+
+ if (pdf_is_indirect(ctx, resources))
+ pdf_dict_put_drop(ctx, page_obj, PDF_NAME_Resources, resources);
+ else if (pdf_is_dict(ctx, resources))
+ pdf_dict_put_drop(ctx, page_obj, PDF_NAME_Resources, pdf_add_object(ctx, doc, resources));
+ else
+ pdf_dict_put_drop(ctx, page_obj, PDF_NAME_Resources, pdf_new_dict(ctx, doc, 1));
+
+ if (contents)
+ pdf_dict_put_drop(ctx, page_obj, PDF_NAME_Contents, pdf_add_stream(ctx, doc, contents, NULL, 0));
}
fz_catch(ctx)
{