summaryrefslogtreecommitdiff
path: root/base/gxcpath.c
diff options
context:
space:
mode:
authorKen Sharp <ken.sharp@artifex.com>2020-05-12 13:58:30 +0100
committerKen Sharp <ken.sharp@artifex.com>2020-05-12 13:58:30 +0100
commitbad9f11895cbb4c0f53b7b0ef8f3502789d81315 (patch)
tree871df8dd386f938bb366fba35b18dc393cf3b72a /base/gxcpath.c
parentae6b0b0e768f618728f66580227fffc92896903c (diff)
downloadghostpdl-bad9f11895cbb4c0f53b7b0ef8f3502789d81315.tar.gz
graphics library - improve gx_cpath_copy
This function does not, currently, appear to be called from anywhere. For the new PDF interpreter we'd like to use it to copy the clip path(s) from the PostScript environment to the PDF environment, but there's a problem. The problem is that the structures defining the list of rectangles are allocated using the same memory allocator as the source clip path, but when we come to free them, the destructor uses the memory allocator of the clip list. So if the destination clip path was using a different allocator from the source clip path, we will use the wrong allocator to try and free the memory. Chris thinks this may be an attempt to cope with stack-based allocations of the clip path where the allocator is NULL. So to cope with that we use the existing code (allocator from the source clip path) if the destination clip path's allocator is NULL (stack based) and we use the destination clip path's allocator otherwise.
Diffstat (limited to 'base/gxcpath.c')
-rw-r--r--base/gxcpath.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/base/gxcpath.c b/base/gxcpath.c
index 082c3890b..c9fde9d49 100644
--- a/base/gxcpath.c
+++ b/base/gxcpath.c
@@ -1122,7 +1122,11 @@ gx_cpath_copy(const gx_clip_path * from, gx_clip_path * pcpath)
pcpath->cached = NULL;
l->single = from->rect_list->list.single;
for (r = from->rect_list->list.head; r != NULL; r = r->next) {
- s = gs_alloc_struct(from->rect_list->rc.memory, gx_clip_rect, &st_clip_rect, "gx_cpath_copy");
+ if (pcpath->rect_list->rc.memory == NULL)
+ s = gs_alloc_struct(from->rect_list->rc.memory, gx_clip_rect, &st_clip_rect, "gx_cpath_copy");
+ else
+ s = gs_alloc_struct(pcpath->rect_list->rc.memory, gx_clip_rect, &st_clip_rect, "gx_cpath_copy");
+
if (s == NULL)
return_error(gs_error_VMerror);
*s = *r;