summaryrefslogtreecommitdiff
path: root/psi/iutil.c
diff options
context:
space:
mode:
authorChris Liddell <chris.liddell@artifex.com>2022-02-28 13:09:17 +0000
committerChris Liddell <chris.liddell@artifex.com>2022-02-28 15:47:42 +0000
commit08c198c4043b516998ff43837fb273eb23b55819 (patch)
tree5c880803183be859cb2b1232feafd2c715b97174 /psi/iutil.c
parent0366ea2396b0d101b8e321c1e28a1a4610c0fbf4 (diff)
downloadghostpdl-08c198c4043b516998ff43837fb273eb23b55819.tar.gz
Bug 705015: Improve handling of device references from Postscript
Ghostscript has multiple memory management models, of particular interest here are the mark, sweep and relocate garbage collection, and reference counting. Postscript objects rely on garbage collection, most internal objects utilize reference counting. In this case, Ghostscript devices are reference counted but also allocated in garbage collected memory - so are subject to both models. A problem arises when Ghostscript device objects are referenced by Postscript, previously such references were not reference counted where internal references are. So Postscript like "gsave nulldevice currentdevice grestore setdevice" would crash because the "nulldevice" created after the gsave was freed (by reference count) by the grestore, despite a remaining reference from the Postscript operand stack. This modifies the approach so Postscript references a "device container" object, and the container object references the device. The container object is garbage collected, and the device is reference counted. The device container object has a finalize method, so just before it is freed, the finalize can decrement the reference count of the device. That allows us to maintain the consistency of the device reference count, even through the Postscript interpreter. Also remove the solution for a previous, related problem, which this fix makes redundant.
Diffstat (limited to 'psi/iutil.c')
-rw-r--r--psi/iutil.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/psi/iutil.c b/psi/iutil.c
index a5fb3a470..39a0a3162 100644
--- a/psi/iutil.c
+++ b/psi/iutil.c
@@ -176,7 +176,7 @@ obj_eq(const gs_memory_t *mem, const ref * pref1, const ref * pref2)
return (!bytes_compare(pref1->value.bytes, r_size(pref1),
pref2->value.bytes, r_size(pref2)));
case t_device:
- return (pref1->value.pdevice == pref2->value.pdevice);
+ return (pref1->value.pdevice->device == pref2->value.pdevice->device);
case t_struct:
case t_astruct:
case t_pdfctx: