diff options
author | Robin Watts <robin.watts@artifex.com> | 2013-09-04 17:32:42 +0100 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2013-09-04 17:38:46 +0100 |
commit | 515c0106845a7dafd71abba6b29305e39c88380e (patch) | |
tree | 833a5b0d5dafc4eca3c074b37f95e5428d656e6d /source/pdf | |
parent | 53236ad1f567cec4509351a0cc056a64ebd97a9e (diff) | |
download | mupdf-515c0106845a7dafd71abba6b29305e39c88380e.tar.xz |
Fix memory leak due to softmasks.
A user (sebblonline) reports a problem when rendering the 300Meg
document downloadable from:
http://www.mitsubishicarbide.com/EU/de/product/epaper/index.html
(7th icon on the bottom). Memento builds report that softmask objects
are leaked.
Tracing these it appears that the handling of softmasks in
pdf_run_xobject is not quite nested right. Fixing this reveals another
problem with clipping paths being doubly removed. Adding a gsave/grestore
pair solves this and leaves us with a well behaved program.
Diffstat (limited to 'source/pdf')
-rw-r--r-- | source/pdf/pdf-interpret.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/source/pdf/pdf-interpret.c b/source/pdf/pdf-interpret.c index 0ed30026..9de4c833 100644 --- a/source/pdf/pdf-interpret.c +++ b/source/pdf/pdf-interpret.c @@ -1548,8 +1548,9 @@ pdf_run_xobject(pdf_csi *csi, pdf_obj *resources, pdf_xobject *xobj, const fz_ma gstate->fill.alpha = 1; } - /* clip to the bounds */ + pdf_gsave(csi); /* Save here so the clippath doesn't persist */ + /* clip to the bounds */ fz_moveto(ctx, csi->path, xobj->bbox.x0, xobj->bbox.y0); fz_lineto(ctx, csi->path, xobj->bbox.x1, xobj->bbox.y0); fz_lineto(ctx, csi->path, xobj->bbox.x1, xobj->bbox.y1); @@ -1567,6 +1568,15 @@ pdf_run_xobject(pdf_csi *csi, pdf_obj *resources, pdf_xobject *xobj, const fz_ma } fz_always(ctx) { + pdf_grestore(csi); /* Remove the clippath */ + + /* wrap up transparency stacks */ + if (xobj->transparency) + { + fz_end_group(csi->dev); + end_softmask(csi, &softmask); + } + csi->gstate[csi->gparent].ctm = gparent_save_ctm; csi->gparent = gparent_save; @@ -1579,13 +1589,6 @@ pdf_run_xobject(pdf_csi *csi, pdf_obj *resources, pdf_xobject *xobj, const fz_ma } pdf_unmark_obj(xobj->me); - - /* wrap up transparency stacks */ - if (xobj->transparency) - { - fz_end_group(csi->dev); - end_softmask(csi, &softmask); - } } fz_catch(ctx) { |