diff options
author | Robin Watts <Robin.Watts@artifex.com> | 2019-07-04 18:52:08 +0100 |
---|---|---|
committer | Robin Watts <Robin.Watts@artifex.com> | 2019-07-05 12:05:09 +0100 |
commit | dd2bd7b4ca1886a4f3c58afbdacbb93831c57e1b (patch) | |
tree | d6944ca88147c3090c65675f9ff20996a4a20849 /base/gstrans.c | |
parent | 47a4fab32690cd2f0aba92f37fc7f03b4069460a (diff) | |
download | ghostpdl-dd2bd7b4ca1886a4f3c58afbdacbb93831c57e1b.tar.gz |
Bug 701284: Fix leak of pdf14device in xps.
The pdf14device is created and then "retained". This is required
for gs, because postscript can call "currentdevice" and get a
non reference counted pointer to a device. It is cleared up
correctly because of gc.
Other languages have no gc, and so leak. The fix is to enable
those languages to get the pdf14device "unretained". We add an
graphics lib call to allow this to happen.
Transparent Patterns also create pdf14devices, which are again
retained, despite not needing to be. In gs this causes no problems
as they are cleared by the restore, but in other languages they
leak. We make them unretained here, with no ill effects.
Diffstat (limited to 'base/gstrans.c')
-rw-r--r-- | base/gstrans.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/base/gstrans.c b/base/gstrans.c index 201467cdb..a534f3075 100644 --- a/base/gstrans.c +++ b/base/gstrans.c @@ -155,7 +155,7 @@ check_for_nontrans_pattern(gs_gstate *pgs, unsigned char *comp_name) * compositor device. */ static int -gs_gstate_update_pdf14trans(gs_gstate * pgs, gs_pdf14trans_params_t * pparams) +gs_gstate_update_pdf14trans2(gs_gstate * pgs, gs_pdf14trans_params_t * pparams, bool retain_on_create) { gx_device * dev = pgs->device; gx_device *pdf14dev = NULL; @@ -174,6 +174,7 @@ gs_gstate_update_pdf14trans(gs_gstate * pgs, gs_pdf14trans_params_t * pparams) */ if (pdf14dev != dev) { gx_set_device_only(pgs, pdf14dev); + gx_device_retain(pdf14dev, retain_on_create); } /* If we had a color space change and we are in overprint, then we need to @@ -185,6 +186,12 @@ gs_gstate_update_pdf14trans(gs_gstate * pgs, gs_pdf14trans_params_t * pparams) return code; } +static int +gs_gstate_update_pdf14trans(gs_gstate * pgs, gs_pdf14trans_params_t * pparams) +{ + return gs_gstate_update_pdf14trans2(pgs, pparams, true); +} + void gs_trans_group_params_init(gs_transparency_group_params_t *ptgp) { @@ -787,7 +794,7 @@ get_num_pdf14_spot_colors(gs_gstate * pgs) } int -gs_push_pdf14trans_device(gs_gstate * pgs, bool is_pattern) +gs_push_pdf14trans_device(gs_gstate * pgs, bool is_pattern, bool retain) { gs_pdf14trans_params_t params = { 0 }; cmm_profile_t *icc_profile; @@ -818,7 +825,7 @@ gs_push_pdf14trans_device(gs_gstate * pgs, bool is_pattern) params.iccprofile = pgs->icc_manager->default_rgb; } /* Note: Other parameters not used */ - return gs_gstate_update_pdf14trans(pgs, ¶ms); + return gs_gstate_update_pdf14trans2(pgs, ¶ms, retain); } int |