summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorSebastian Rasmussen <sebras@gmail.com>2018-10-03 16:52:48 +0800
committerTor Andersson <tor.andersson@artifex.com>2018-10-24 14:17:01 +0200
commit0ede62fb205d0f81f3491152b5721e835d5ba7d4 (patch)
tree6e940a79213beee05e70ca5a8a0d4951397a18af /source
parent645b5eb857310819fc66d73c32751958439f5d12 (diff)
downloadmupdf-0ede62fb205d0f81f3491152b5721e835d5ba7d4.tar.xz
Drop page upon exception verifying page signatures.
Diffstat (limited to 'source')
-rw-r--r--source/tools/pdfsign.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/source/tools/pdfsign.c b/source/tools/pdfsign.c
index b9b1c862..0497fdd0 100644
--- a/source/tools/pdfsign.c
+++ b/source/tools/pdfsign.c
@@ -40,10 +40,11 @@ void verify_page(fz_context *ctx, pdf_document *doc, int n, pdf_page *page)
int pdfsign_main(int argc, char **argv)
{
- fz_context *ctx = NULL;
- pdf_document *doc = NULL;
+ fz_context *ctx;
+ pdf_document *doc;
char *password = "";
int i, n, c;
+ pdf_page *page = NULL;
while ((c = fz_getopt(argc, argv, "p:")) != -1)
{
@@ -66,9 +67,11 @@ int pdfsign_main(int argc, char **argv)
exit(1);
}
+ fz_var(page);
+
+ doc = pdf_open_document(ctx, filename);
fz_try(ctx)
{
- doc = pdf_open_document(ctx, filename);
if (pdf_needs_password(ctx, doc))
if (!pdf_authenticate_password(ctx, doc, password))
fz_warn(ctx, "cannot authenticate password: %s", filename);
@@ -76,16 +79,20 @@ int pdfsign_main(int argc, char **argv)
n = pdf_count_pages(ctx, doc);
for (i = 0; i < n; ++i)
{
- pdf_page *page = pdf_load_page(ctx, doc, i);
+ page = pdf_load_page(ctx, doc, i);
verify_page(ctx, doc, i, page);
fz_drop_page(ctx, (fz_page*)page);
+ page = NULL;
}
}
+ fz_always(ctx)
+ pdf_drop_document(ctx, doc);
fz_catch(ctx)
{
+ fz_drop_page(ctx, (fz_page*)page);
+ fprintf(stderr, "error verify signatures: %s\n", fz_caught_message(ctx));
}
- pdf_drop_document(ctx, doc);
fz_flush_warnings(ctx);
fz_drop_context(ctx);
return 0;