summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKen Sharp <ken.sharp@artifex.com>2020-09-07 09:54:28 +0100
committerKen Sharp <ken.sharp@artifex.com>2020-09-07 09:54:28 +0100
commit2202026393550166416b4fd28daaa4f667a77301 (patch)
tree51fffab48fe5a0edcabfd39103b80c3b07c68f29
parent2c2fab370060e84b55c74c1c99fa1a8046a5b4f8 (diff)
downloadghostpdl-2202026393550166416b4fd28daaa4f667a77301.tar.gz
Fix memory leak with clip device and image width/height = 0
When rendering masked images we can create a clip device in order to do the actual masking before passing the result to the final device. After creating the device we store it in a 'gs_image_common_enum' for later use. We then proceed to initialise the main image enumerator in gs_image_common_init(). As an optimisation, if the image width or height is 0, we don't waste any time processing it but simply end the image and exit. However, if we had created a clip device, we did not free that device leading to a memory leak. This commit simply 'un-retains' the device causing it to be freed.
-rw-r--r--base/gsimage.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/base/gsimage.c b/base/gsimage.c
index d62c76eb7..7afea3358 100644
--- a/base/gsimage.c
+++ b/base/gsimage.c
@@ -408,7 +408,12 @@ gs_image_common_init(gs_image_enum * penum, gx_image_enum_common_t * pie,
int i;
if (pim->Width == 0 || pim->Height == 0) {
+ gx_device *cdev = pie->dev;
+
gx_image_end(pie, false);
+ if (dev_proc(cdev, dev_spec_op)(cdev,
+ gxdso_pattern_is_cpath_accum, NULL, 0))
+ gx_device_retain((gx_device *)cdev, false);
return 1;
}
image_enum_init(penum);