summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gs/base/gdevp14.c2
-rw-r--r--gs/base/gxcpath.c16
-rw-r--r--gs/base/gxfill.c2
-rw-r--r--gs/base/gxpath.h9
4 files changed, 24 insertions, 5 deletions
diff --git a/gs/base/gdevp14.c b/gs/base/gdevp14.c
index 49f252b7e..886015b36 100644
--- a/gs/base/gdevp14.c
+++ b/gs/base/gdevp14.c
@@ -2297,7 +2297,7 @@ pdf14_tile_pattern_fill(gx_device * pdev, const gs_imager_state * pis,
gx_path path_ttrans;
if (pcpath != NULL) {
- code = gx_cpath_init_local_shared(&cpath_intersection, pcpath, ppath->memory);
+ code = gx_cpath_init_local_shared_nested(&cpath_intersection, pcpath, ppath->memory, 1);
if (code < 0)
return code;
} else {
diff --git a/gs/base/gxcpath.c b/gs/base/gxcpath.c
index b07c6f9bc..d0ada3762 100644
--- a/gs/base/gxcpath.c
+++ b/gs/base/gxcpath.c
@@ -209,11 +209,14 @@ gx_cpath_alloc_shared(const gx_clip_path * shared, gs_memory_t * mem,
/* Initialize a stack-allocated clipping path. */
int
-gx_cpath_init_local_shared(gx_clip_path * pcpath, const gx_clip_path * shared,
- gs_memory_t * mem)
+gx_cpath_init_local_shared_nested(gx_clip_path * pcpath,
+ const gx_clip_path * shared,
+ gs_memory_t * mem,
+ bool safely_nested)
{
if (shared) {
- if (shared->path.segments == &shared->path.local_segments) {
+ if ((shared->path.segments == &shared->path.local_segments) &&
+ !safely_nested) {
lprintf1("Attempt to share (local) segments of clip path 0x%lx!\n",
(ulong) shared);
return_error(gs_error_Fatal);
@@ -236,6 +239,13 @@ gx_cpath_init_local_shared(gx_clip_path * pcpath, const gx_clip_path * shared,
return 0;
}
+int
+gx_cpath_init_local_shared(gx_clip_path * pcpath, const gx_clip_path * shared,
+ gs_memory_t * mem)
+{
+ return gx_cpath_init_local_shared_nested(pcpath, shared, mem, 0);
+}
+
/* Unshare a clipping path. */
int
gx_cpath_unshare(gx_clip_path * pcpath)
diff --git a/gs/base/gxfill.c b/gs/base/gxfill.c
index 9050d67d7..c568c4bd5 100644
--- a/gs/base/gxfill.c
+++ b/gs/base/gxfill.c
@@ -590,7 +590,7 @@ gx_default_fill_path(gx_device * pdev, const gs_imager_state * pis,
gs_imager_state *pis_noconst = (gs_imager_state *)pis; /* Break const. */
if (ppath != NULL) {
- code = gx_cpath_init_local_shared(&cpath_intersection, pcpath, pdev->memory);
+ code = gx_cpath_init_local_shared_nested(&cpath_intersection, pcpath, pdev->memory, 1);
if (code < 0)
return code;
if (pcpath == NULL) {
diff --git a/gs/base/gxpath.h b/gs/base/gxpath.h
index e4985611d..b8dedafd7 100644
--- a/gs/base/gxpath.h
+++ b/gs/base/gxpath.h
@@ -317,6 +317,15 @@ int gx_cpath_init_contained_shared(gx_clip_path * pcpath,
int gx_cpath_init_local_shared(gx_clip_path * pcpath,
const gx_clip_path * shared,
gs_memory_t * mem);
+/* Function that informs us that the usage of this cpath will be
+ * safely nested within the existence of the 'shared' one. i.e.
+ * we don't need to worry that the shared one may go away while
+ * we contain pointers to it.
+ */
+int gx_cpath_init_local_shared_nested(gx_clip_path * pcpath,
+ const gx_clip_path * shared,
+ gs_memory_t * mem,
+ bool safely_nested);
#define gx_cpath_init_local(pcpath, mem)\
(void)gx_cpath_init_local_shared(pcpath, NULL, mem) /* can't fail */