summaryrefslogtreecommitdiff
path: root/base
diff options
context:
space:
mode:
authorRobin Watts <Robin.Watts@artifex.com>2019-07-04 18:52:08 +0100
committerRobin Watts <Robin.Watts@artifex.com>2019-07-05 12:05:09 +0100
commitdd2bd7b4ca1886a4f3c58afbdacbb93831c57e1b (patch)
treed6944ca88147c3090c65675f9ff20996a4a20849 /base
parent47a4fab32690cd2f0aba92f37fc7f03b4069460a (diff)
downloadghostpdl-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')
-rw-r--r--base/gstrans.c13
-rw-r--r--base/gstrans.h2
-rw-r--r--base/gxpcmap.c2
3 files changed, 12 insertions, 5 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, &params);
+ return gs_gstate_update_pdf14trans2(pgs, &params, retain);
}
int
diff --git a/base/gstrans.h b/base/gstrans.h
index 25180072a..ab64d174b 100644
--- a/base/gstrans.h
+++ b/base/gstrans.h
@@ -161,7 +161,7 @@ bool gs_currenttextknockout(const gs_gstate *);
* We have to abbreviate the procedure name because procedure names are
* only unique to 23 characters on VMS.
*/
-int gs_push_pdf14trans_device(gs_gstate * pgs, bool is_pattern);
+int gs_push_pdf14trans_device(gs_gstate * pgs, bool is_pattern, bool retain);
int gs_pop_pdf14trans_device(gs_gstate * pgs, bool is_pattern);
diff --git a/base/gxpcmap.c b/base/gxpcmap.c
index 2f014e0d6..5b647bfe0 100644
--- a/base/gxpcmap.c
+++ b/base/gxpcmap.c
@@ -1460,7 +1460,7 @@ gx_pattern_load(gx_device_color * pdc, const gs_gstate * pgs,
goto fail;
if (pinst->templat.uses_transparency) {
if_debug0m('v', mem, "gx_pattern_load: pushing the pdf14 compositor device into this graphics state\n");
- if ((code = gs_push_pdf14trans_device(saved, true)) < 0)
+ if ((code = gs_push_pdf14trans_device(saved, true, false)) < 0)
return code;
saved->device->is_open = true;
} else {