summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKen Sharp <ken.sharp@artifex.com>2012-02-08 15:01:57 +0000
committerChris Liddell <chris.liddell@artifex.com>2012-03-15 11:54:20 +0000
commit35343e1b78cc4ab280145333e2fef5b647eda155 (patch)
tree60d4ee88907e67a5707c006af04d392e6d092e7d
parent5048e4a0d37ffc002fba746ed911dcc5f6a07c2f (diff)
Bug #688227 Alter the PostScript 'show' operators so that the show enumerator is in local VM
As described in the bug, it seems to be technically possible for a local font to be referenced from a show enumerator. If the enumerator is in global VM this causes a garbage collector crash. This code modifies the PostScript 'show' family of operators so that the enumerator is always allocated from local VM, avoiding the problem. There is no specimen or method of reproduction supplied in the bug report so this is rather speculative, however it runs a cluster test without problem. If it does cause any problems we should simply revert this change. As part of this change it was noticed that there are a number of procedures defined in gschar.c which are apparently dead code and these have been removed. No expected differences.
-rw-r--r--gs/base/gschar.c165
-rw-r--r--gs/base/gschar.h16
-rw-r--r--gs/psi/zchar.c10
-rw-r--r--gs/psi/zcharx.c4
4 files changed, 9 insertions, 186 deletions
diff --git a/gs/base/gschar.c b/gs/base/gschar.c
index 05afc618f..f8cff6a21 100644
--- a/gs/base/gschar.c
+++ b/gs/base/gschar.c
@@ -24,10 +24,6 @@
#include "gxchar.h"
#include "gxfont.h"
-/* Forward declarations */
-static int show_n_begin(gs_show_enum *penum, gs_state *pgs, int code,
- gs_text_enum_t *pte);
-
/* Structure descriptors */
extern_st(st_gs_show_enum);
@@ -43,165 +39,6 @@ gs_show_enum_release(gs_show_enum * penum, gs_memory_t * emem)
gs_free_object(emem, penum, "gs_show_enum_release");
}
-/* show[_n] */
-int
-gs_show_n_init(gs_show_enum * penum, gs_state * pgs,
- const char *str, uint size)
-{
- gs_text_enum_t *pte;
- int code = gs_show_begin(pgs, (const byte *)str, size, pgs->memory, &pte);
-
- return show_n_begin(penum, pgs, code, pte);
-}
-
-/* ashow[_n] */
-int
-gs_ashow_n_init(gs_show_enum * penum, gs_state * pgs,
- floatp ax, floatp ay, const char *str, uint size)
-{
- gs_text_enum_t *pte;
- int code = gs_ashow_begin(pgs, ax, ay, (const byte *)str, size,
- pgs->memory, &pte);
-
- return show_n_begin(penum, pgs, code, pte);
-}
-
-/* widthshow[_n] */
-int
-gs_widthshow_n_init(gs_show_enum * penum, gs_state * pgs,
- floatp cx, floatp cy, gs_char chr,
- const char *str, uint size)
-{
- gs_text_enum_t *pte;
- int code = gs_widthshow_begin(pgs, cx, cy, chr, (const byte *)str, size,
- pgs->memory, &pte);
-
- return show_n_begin(penum, pgs, code, pte);
-}
-
-/* awidthshow[_n] */
-int
-gs_awidthshow_n_init(gs_show_enum * penum, gs_state * pgs,
- floatp cx, floatp cy, gs_char chr, floatp ax, floatp ay,
- const char *str, uint size)
-{
- gs_text_enum_t *pte;
- int code = gs_awidthshow_begin(pgs, cx, cy, chr, ax, ay,
- (const byte *)str, size, pgs->memory, &pte);
-
- return show_n_begin(penum, pgs, code, pte);
-}
-
-/* kshow[_n] */
-int
-gs_kshow_n_init(gs_show_enum * penum,
- gs_state * pgs, const char *str, uint size)
-{
- gs_text_enum_t *pte;
- int code;
-
- switch (pgs->font->FontType) {
- case ft_composite:
- case ft_CID_encrypted:
- case ft_CID_user_defined:
- case ft_CID_TrueType:
- case ft_CID_bitmap:
- return_error(gs_error_invalidfont);
- default:
- break;
- }
- code = gs_kshow_begin(pgs, (const byte *)str, size, pgs->memory, &pte);
- return show_n_begin(penum, pgs, code, pte);
-}
-
-/* xyshow[_n] */
-int
-gs_xyshow_n_init(gs_show_enum * penum,
- gs_state * pgs, const char *str, uint size)
-{
- gs_text_enum_t *pte;
- int code = gs_xyshow_begin(pgs, (const byte *)str, size, NULL, NULL, 0,
- pgs->memory, &pte);
-
- return show_n_begin(penum, pgs, code, pte);
-}
-
-/* glyphshow */
-int
-gs_glyphshow_init(gs_show_enum * penum, gs_state * pgs, gs_glyph glyph)
-{
- gs_text_enum_t *pte;
- int code = gs_glyphshow_begin(pgs, glyph, pgs->memory, &pte);
-
- return show_n_begin(penum, pgs, code, pte);
-}
-int
-gs_glyphpath_init(gs_show_enum * penum, gs_state * pgs, gs_glyph glyph,
- bool stroke_path)
-{
- gs_text_enum_t *pte;
- int code = gs_glyphpath_begin(pgs, glyph, stroke_path, pgs->memory, &pte);
-
- return show_n_begin(penum, pgs, code, pte);
-}
-int
-gs_glyphwidth_init(gs_show_enum * penum, gs_state * pgs, gs_glyph glyph)
-{
- gs_text_enum_t *pte;
- int code = gs_glyphwidth_begin(pgs, glyph, pgs->memory, &pte);
-
- return show_n_begin(penum, pgs, code, pte);
-}
-
-/* ------ Related operators ------ */
-
-/* cshow[_n] */
-int
-gs_cshow_n_init(gs_show_enum * penum,
- gs_state * pgs, const char *str, uint size)
-{
- gs_text_enum_t *pte;
- int code = gs_cshow_begin(pgs, (const byte *)str, size, pgs->memory, &pte);
-
- return show_n_begin(penum, pgs, code, pte);
-}
-
-/* stringwidth[_n] */
-int
-gs_stringwidth_n_init(gs_show_enum * penum, gs_state * pgs,
- const char *str, uint size)
-{
- gs_text_enum_t *pte;
- int code = gs_stringwidth_begin(pgs, (const byte *)str, size,
- pgs->memory, &pte);
-
- return show_n_begin(penum, pgs, code, pte);
-}
-
-/* charpath[_n] */
-int
-gs_charpath_n_init(gs_show_enum * penum, gs_state * pgs,
- const char *str, uint size, bool stroke_path)
-{
- gs_text_enum_t *pte;
- int code = gs_charpath_begin(pgs, (const byte *)str, size, stroke_path,
- pgs->memory, &pte);
-
- return show_n_begin(penum, pgs, code, pte);
-}
-
-/* charboxpath[_n] */
-int
-gs_charboxpath_n_init(gs_show_enum * penum, gs_state * pgs,
- const char *str, uint size, bool use_boxes)
-{
- gs_text_enum_t *pte;
- int code = gs_charboxpath_begin(pgs, (const byte *)str, size, use_boxes,
- pgs->memory, &pte);
-
- return show_n_begin(penum, pgs, code, pte);
-}
-
/* ------ Width/cache operators ------ */
/* setcachedevice */
@@ -330,6 +167,7 @@ gs_show_width(const gs_show_enum * penum, gs_point * ppt)
/* ------ Internal routines ------ */
+#if 0
/*
* Force the enumerator to be a gs_show_enum *, which the current
* implementation code requires.
@@ -360,3 +198,4 @@ show_n_begin(gs_show_enum *penum, gs_state *pgs, int code, gs_text_enum_t *pte)
gs_free_object(pgs->memory, pte, "show_n_begin");
return code;
}
+#endif
diff --git a/gs/base/gschar.h b/gs/base/gschar.h
index acc676c13..ce342c684 100644
--- a/gs/base/gschar.h
+++ b/gs/base/gschar.h
@@ -41,22 +41,6 @@ gs_show_enum *gs_show_enum_alloc(gs_memory_t *, gs_state *, client_name_t);
/* If the second argument is not NULL, also free the enumerator. */
void gs_show_enum_release(gs_show_enum *, gs_memory_t *);
-/* Initialize a text enumeration. */
-int
- /* PostScript operators */
- gs_show_n_init(gs_show_enum *, gs_state *, const char *, uint),
- gs_ashow_n_init(gs_show_enum *, gs_state *, floatp, floatp, const char *, uint),
- gs_widthshow_n_init(gs_show_enum *, gs_state *, floatp, floatp, gs_char, const char *, uint),
- gs_awidthshow_n_init(gs_show_enum *, gs_state *, floatp, floatp, gs_char, floatp, floatp, const char *, uint),
- gs_kshow_n_init(gs_show_enum *, gs_state *, const char *, uint),
- gs_xyshow_n_init(gs_show_enum *, gs_state *, const char *, uint),
- gs_glyphshow_init(gs_show_enum *, gs_state *, gs_glyph), gs_cshow_n_init(gs_show_enum *, gs_state *, const char *, uint),
- gs_stringwidth_n_init(gs_show_enum *, gs_state *, const char *, uint),
- gs_charpath_n_init(gs_show_enum *, gs_state *, const char *, uint, bool),
- /* Extensions */
- gs_glyphpath_init(gs_show_enum *, gs_state *, gs_glyph, bool),
- gs_glyphwidth_init(gs_show_enum *, gs_state *, gs_glyph),
- gs_charboxpath_n_init(gs_show_enum *, gs_state *, const char *, uint, bool);
int gs_show_use_glyph(gs_show_enum *, gs_glyph);
/* After setting up the enumeration, all the string-related routines */
diff --git a/gs/psi/zchar.c b/gs/psi/zchar.c
index 4cb28727a..d3d6d8567 100644
--- a/gs/psi/zchar.c
+++ b/gs/psi/zchar.c
@@ -55,7 +55,7 @@ zshow(i_ctx_t *i_ctx_p)
int code = op_show_setup(i_ctx_p, op);
if (code != 0 ||
- (code = gs_show_begin(igs, op->value.bytes, r_size(op), imemory, &penum)) < 0)
+ (code = gs_show_begin(igs, op->value.bytes, r_size(op), imemory_local, &penum)) < 0)
return code;
*(op_proc_t *)&penum->enum_client_data = zshow;
if ((code = op_show_finish_setup(i_ctx_p, penum, 1, finish_show)) < 0) {
@@ -76,7 +76,7 @@ zashow(i_ctx_t *i_ctx_p)
if (code < 0 ||
(code = op_show_setup(i_ctx_p, op)) != 0 ||
- (code = gs_ashow_begin(igs, axy[0], axy[1], op->value.bytes, r_size(op), imemory, &penum)) < 0)
+ (code = gs_ashow_begin(igs, axy[0], axy[1], op->value.bytes, r_size(op), imemory_local, &penum)) < 0)
return code;
*(op_proc_t *)&penum->enum_client_data = zashow;
if ((code = op_show_finish_setup(i_ctx_p, penum, 3, finish_show)) < 0) {
@@ -110,7 +110,7 @@ zwidthshow(i_ctx_t *i_ctx_p)
if ((code = gs_widthshow_begin(igs, cxy[0], cxy[1],
(gs_char) op[-1].value.intval,
op->value.bytes, r_size(op),
- imemory, &penum)) < 0)
+ imemory_local, &penum)) < 0)
return code;
*(op_proc_t *)&penum->enum_client_data = zwidthshow;
if ((code = op_show_finish_setup(i_ctx_p, penum, 4, finish_show)) < 0) {
@@ -147,7 +147,7 @@ zawidthshow(i_ctx_t *i_ctx_p)
(gs_char) op[-3].value.intval,
axy[0], axy[1],
op->value.bytes, r_size(op),
- imemory, &penum)) < 0)
+ imemory_local, &penum)) < 0)
return code;
*(op_proc_t *)&penum->enum_client_data = zawidthshow;
if ((code = op_show_finish_setup(i_ctx_p, penum, 6, finish_show)) < 0) {
@@ -176,7 +176,7 @@ zkshow(i_ctx_t *i_ctx_p)
return_error(e_invalidfont);
if ((code = op_show_setup(i_ctx_p, op)) != 0 ||
(code = gs_kshow_begin(igs, op->value.bytes, r_size(op),
- imemory, &penum)) < 0)
+ imemory_local, &penum)) < 0)
return code;
*(op_proc_t *)&penum->enum_client_data = zkshow;
if ((code = op_show_finish_setup(i_ctx_p, penum, 2, finish_show)) < 0) {
diff --git a/gs/psi/zcharx.c b/gs/psi/zcharx.c
index 6bdf1c24c..9ba1dba69 100644
--- a/gs/psi/zcharx.c
+++ b/gs/psi/zcharx.c
@@ -57,7 +57,7 @@ zglyphshow(i_ctx_t *i_ctx_p)
int code;
if ((code = glyph_show_setup(i_ctx_p, &glyph)) != 0 ||
- (code = gs_glyphshow_begin(igs, glyph, imemory, &penum)) < 0)
+ (code = gs_glyphshow_begin(igs, glyph, imemory_local, &penum)) < 0)
return code;
*(op_proc_t *)&penum->enum_client_data = zglyphshow;
if ((code = op_show_finish_setup(i_ctx_p, penum, 1, NULL)) < 0) {
@@ -113,7 +113,7 @@ moveshow(i_ctx_t *i_ctx_p, bool have_x, bool have_y)
if ((code = gs_xyshow_begin(igs, op[-1].value.bytes, r_size(op - 1),
(have_x ? values : (float *)0),
(have_y ? values : (float *)0),
- size, imemory, &penum)) < 0) {
+ size, imemory_local, &penum)) < 0) {
ifree_object(values, "moveshow");
return code;
}