summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2011-08-09 17:44:13 +0200
committerTor Andersson <tor.andersson@artifex.com>2011-08-09 17:44:13 +0200
commit4214d2a553522a9ebb5c263368131aea813ebe03 (patch)
treebcfa92eb0e54591f75189f3421051933ca1bacf1
parentb2cd282be719c196c77d90b78415807a5d6da2aa (diff)
downloadmupdf-4214d2a553522a9ebb5c263368131aea813ebe03.tar.xz
Fix bug 692312.
Make sure the CSI works from a clean slate in pdf_run_stream, since it may be called to draw a softmask form pdf_flush_text in the middle of parsing a TJ text array. Also guard against xobject failures by catching instead of rethrowing xobject parse errors so that the begin and end group draw calls are balanced.
-rw-r--r--pdf/pdf_interpret.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/pdf/pdf_interpret.c b/pdf/pdf_interpret.c
index 998c2672..827678e5 100644
--- a/pdf/pdf_interpret.c
+++ b/pdf/pdf_interpret.c
@@ -1086,7 +1086,7 @@ pdf_run_xobject(pdf_csi *csi, fz_obj *resources, pdf_xobject *xobj, fz_matrix tr
error = pdf_run_buffer(csi, resources, xobj->contents);
if (error)
- return fz_rethrow(error, "cannot interpret XObject stream");
+ fz_catch(error, "cannot interpret XObject stream");
csi->top_ctm = oldtopctm;
@@ -2116,8 +2116,15 @@ pdf_run_stream(pdf_csi *csi, fz_obj *rdb, fz_stream *file, char *buf, int buflen
fz_error error;
int tok;
int len;
+ int save_in_array;
+ int save_in_text;
+ /* make sure we have a clean slate if we come here from flush_text */
pdf_clear_stack(csi);
+ save_in_array = csi->in_array;
+ save_in_text = csi->in_text;
+ csi->in_array = 0;
+ csi->in_text = 0;
while (1)
{
@@ -2151,7 +2158,7 @@ pdf_run_stream(pdf_csi *csi, fz_obj *rdb, fz_stream *file, char *buf, int buflen
return fz_throw("syntax error in array");
}
else if (tok == PDF_TOK_EOF)
- return fz_okay;
+ goto end;
else
return fz_throw("syntax error in array");
}
@@ -2160,7 +2167,7 @@ pdf_run_stream(pdf_csi *csi, fz_obj *rdb, fz_stream *file, char *buf, int buflen
{
case PDF_TOK_ENDSTREAM:
case PDF_TOK_EOF:
- return fz_okay;
+ goto end;
case PDF_TOK_OPEN_ARRAY:
if (!csi->in_text)
@@ -2218,6 +2225,11 @@ pdf_run_stream(pdf_csi *csi, fz_obj *rdb, fz_stream *file, char *buf, int buflen
return fz_throw("syntax error in content stream");
}
}
+
+end:
+ csi->in_array = save_in_array;
+ csi->in_text = save_in_text;
+ return fz_okay;
}
/*