summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Liddell <chris.liddell@artifex.com>2018-11-06 16:46:02 +0000
committerChris Liddell <chris.liddell@artifex.com>2018-11-06 17:57:46 +0000
commit6dd9131bfa9bd2d723e745839e4bc8e5fdc817b7 (patch)
tree622556dbd10bc016b5bd09a1b59e0e3ae13cf6dc
parent30ef5d0b5b14d3f4eaf7929b81aec2279933e1cc (diff)
downloadghostpdl-6dd9131bfa9bd2d723e745839e4bc8e5fdc817b7.tar.gz
Ensure stream and string persist as long as required
When we create an ICC based color space from a string source, we create a stream object, with the stream data coming from that string. Because the life of the ICC related objects created by the graphics library is not dictated by the save/restore operations in the Postscript world, we need to ensure that the stream and the string it references persist as long as the graphics library needs. To do this, we move the string data, and the stream object allocation into "system VM", that is, garbage collected, but *not* save/restore memory.
-rw-r--r--psi/zcolor.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/psi/zcolor.c b/psi/zcolor.c
index 0409f62be..74b428801 100644
--- a/psi/zcolor.c
+++ b/psi/zcolor.c
@@ -5508,10 +5508,20 @@ static int seticcspace(i_ctx_t * i_ctx_p, ref *r, int *stage, int *cont, int CIE
if (r_has_type(tempref, t_string)){
uint n = r_size(tempref);
ref rss;
+ byte *body;
+ uint save_space = icurrent_space;
- code = make_rss(i_ctx_p, &rss, tempref->value.const_bytes, n, r_space(tempref), 0L, n, false);
- if (code < 0)
+ ialloc_set_space(idmemory, avm_system);
+ body = ialloc_string(n, "seticcspace");
+ ialloc_set_space(idmemory, save_space);
+ if (!body)
+ return_error(gs_error_VMerror);
+ memcpy(body, tempref->value.const_bytes, n);
+ code = make_rss(i_ctx_p, &rss, body, n, avm_system, 0L, n, false);
+ if (code < 0) {
+ ifree_string(body, n, "seticcspace");
return code;
+ }
ref_assign(tempref, &rss);
}
/* Make space on operand stack to pass the ICC dictionary */