summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2018-10-24 17:10:42 +0200
committerTor Andersson <tor.andersson@artifex.com>2018-10-24 17:11:22 +0200
commit54728872f059b0422e392f92cc988f3a50ff117c (patch)
treee195bd6f7760c93fb354a97a3518d8b7488f25d1 /source
parentc813d8a59ebadcfcf946c7ba7c13af7f33a5f022 (diff)
downloadmupdf-54728872f059b0422e392f92cc988f3a50ff117c.tar.xz
Do run processor clip stack balancing in close (not drop) callback.
The close callback should make sure everything is cleanly shut down. The drop callback frees leftover memory when shutting down either cleanly or when aborting processing due to errors.
Diffstat (limited to 'source')
-rw-r--r--source/pdf/pdf-op-run.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/source/pdf/pdf-op-run.c b/source/pdf/pdf-op-run.c
index 2b6edea4..f0ce5e9d 100644
--- a/source/pdf/pdf-op-run.c
+++ b/source/pdf/pdf-op-run.c
@@ -2199,21 +2199,30 @@ static void pdf_run_END(fz_context *ctx, pdf_processor *proc)
}
static void
-pdf_drop_run_processor(fz_context *ctx, pdf_processor *proc)
+pdf_close_run_processor(fz_context *ctx, pdf_processor *proc)
{
pdf_run_processor *pr = (pdf_run_processor *)proc;
while (pr->gtop)
pdf_grestore(ctx, pr);
- pdf_drop_material(ctx, &pr->gstate[0].fill);
- pdf_drop_material(ctx, &pr->gstate[0].stroke);
- pdf_drop_font(ctx, pr->gstate[0].text.font);
- pdf_drop_obj(ctx, pr->gstate[0].softmask);
- fz_drop_stroke_state(ctx, pr->gstate[0].stroke_state);
-
- while (pr->gstate[0].clip_depth--)
+ while (pr->gstate[0].clip_depth)
+ {
fz_pop_clip(ctx, pr->dev);
+ pr->gstate[0].clip_depth--;
+ }
+}
+
+static void
+pdf_drop_run_processor(fz_context *ctx, pdf_processor *proc)
+{
+ pdf_run_processor *pr = (pdf_run_processor *)proc;
+
+ while (pr->gtop >= 0)
+ {
+ pdf_drop_gstate(ctx, &pr->gstate[pr->gtop]);
+ pr->gtop--;
+ }
fz_drop_path(ctx, pr->path);
fz_drop_text(ctx, pr->tos.text);
@@ -2230,6 +2239,7 @@ pdf_new_run_processor(fz_context *ctx, fz_device *dev, fz_matrix ctm, const char
{
proc->super.usage = usage;
+ proc->super.close_processor = pdf_close_run_processor;
proc->super.drop_processor = pdf_drop_run_processor;
/* general graphics state */