summaryrefslogtreecommitdiff
path: root/base/gxpcmap.c
diff options
context:
space:
mode:
authorChris Liddell <chris.liddell@artifex.com>2022-08-09 12:16:09 +0100
committerChris Liddell <chris.liddell@artifex.com>2022-08-09 16:30:14 +0100
commitb56a8977fc1e3bb88b06b830fdeb9b6622d53d49 (patch)
treecc56dd3ccfece6717206880d5019700909826cdf /base/gxpcmap.c
parent0f6330e587abaa768c1c5d82f5b36ed085ae967b (diff)
downloadghostpdl-b56a8977fc1e3bb88b06b830fdeb9b6622d53d49.tar.gz
Bug 705733: Improve pattern error cleanup
Type 1 patterns are loaded lazily, and normal cleanup occurs when the pattern tile is ejected from the tile cache. But in this case, the pattern triggers an error in the transparency code, meaning the pattern tile is never added to the cache. This causes a memory leak in gpdf, and a crash in the gs garbage collector when shutting down the PS interpreter (when pdfi is called via gs). We now ensure the pattern accumulator device is destroyed in the event of such an error, meaning no spurious references to the pattern, the target device nor the contents of the pattern instance remain to cause problems.
Diffstat (limited to 'base/gxpcmap.c')
-rw-r--r--base/gxpcmap.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/base/gxpcmap.c b/base/gxpcmap.c
index 4a58c170a..e8b28b641 100644
--- a/base/gxpcmap.c
+++ b/base/gxpcmap.c
@@ -1586,7 +1586,7 @@ gx_pattern_load(gx_device_color * pdc, const gs_gstate * pgs,
/* Send the compositor command to close the PDF14 device */
code = gs_pop_pdf14trans_device(saved, true);
if (code < 0)
- return code;
+ goto fail;
} else {
/* Not a clist, get PDF14 buffer information */
code =
@@ -1597,7 +1597,7 @@ gx_pattern_load(gx_device_color * pdc, const gs_gstate * pgs,
/* PDF14 device (and buffer) is destroyed when pattern cache
entry is removed */
if (code < 0)
- return code;
+ goto fail;
}
}
/* We REALLY don't like the following cast.... */
@@ -1646,6 +1646,8 @@ fail:
cdev->common.data = 0;
}
dev_proc(adev, close_device)((gx_device *)adev);
+ gx_device_set_target(adev, NULL);
+ rc_decrement(adev, "gx_pattern_load");
gs_gstate_free_chain(saved);
return code;
}