summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2012-01-09 11:32:04 +0000
committerRobin Watts <robin@ghostscript.com>2012-01-09 18:52:32 +0000
commit41826915a2abe9ef1586c7cd58ae2af9d6a07fd3 (patch)
tree01ddc3559f7eb033162f7b5f717acd29a6bb7cf6 /apps
parent828c7bc9bf140d04a85b27ba91d0825e236eab01 (diff)
downloadmupdf-41826915a2abe9ef1586c7cd58ae2af9d6a07fd3.tar.xz
Add fz_try/fz_catch to xpsdraw
Avoid unhandled exceptions. Thanks to Zeniko for this.
Diffstat (limited to 'apps')
-rw-r--r--apps/xpsdraw.c41
1 files changed, 25 insertions, 16 deletions
diff --git a/apps/xpsdraw.c b/apps/xpsdraw.c
index 33fb9db2..930185ae 100644
--- a/apps/xpsdraw.c
+++ b/apps/xpsdraw.c
@@ -284,9 +284,11 @@ int main(int argc, char **argv)
{
int grayscale = 0;
int accelerate = 1;
- xps_document *doc;
+ xps_document *doc = NULL;
int c;
+ fz_var(doc);
+
while ((c = fz_getopt(argc, argv, "o:p:r:Aadglmtx5")) != -1)
{
switch (c)
@@ -349,26 +351,33 @@ int main(int argc, char **argv)
{
filename = argv[fz_optind++];
- doc = xps_open_file(ctx, filename);
+ fz_try(ctx)
+ {
+ doc = xps_open_file(ctx, filename);
- if (showxml)
- printf("<document name=\"%s\">\n", filename);
+ if (showxml)
+ printf("<document name=\"%s\">\n", filename);
- if (showoutline)
- drawoutline(doc);
+ if (showoutline)
+ drawoutline(doc);
- if (showtext || showxml || showtime || showmd5 || output)
- {
- if (fz_optind == argc || !isrange(argv[fz_optind]))
- drawrange(doc, "1-");
- if (fz_optind < argc && isrange(argv[fz_optind]))
- drawrange(doc, argv[fz_optind++]);
- }
+ if (showtext || showxml || showtime || showmd5 || output)
+ {
+ if (fz_optind == argc || !isrange(argv[fz_optind]))
+ drawrange(doc, "1-");
+ if (fz_optind < argc && isrange(argv[fz_optind]))
+ drawrange(doc, argv[fz_optind++]);
+ }
- if (showxml)
- printf("</document>\n");
+ if (showxml)
+ printf("</document>\n");
- xps_free_context(doc);
+ xps_free_context(doc);
+ }
+ fz_catch(ctx)
+ {
+ xps_free_context(doc);
+ }
}
if (showtime)