summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Johnston <ray.johnston@artifex.com>2012-04-16 10:32:06 -0700
committerRay Johnston <ray.johnston@artifex.com>2012-04-16 10:32:06 -0700
commitadb39bd6b16e20c7c6cf235518fc98ab242552e7 (patch)
tree065c95648edb0e627ec2486b0b53000f714cb4fc
parent67894626809b89f813d3ed580210ee11da72af52 (diff)
Fix segfault caused by change in zcharx (34f32ee) seen with 11-13.PS.
Under some error conditions, the 'penum' was not being set, and we would de-reference whatever (undefined) value was laying around. Initialize it to NULL and check before clearing pointers. I couldn't get this to fail in a debug or profile build -- only a release build.
-rw-r--r--gs/psi/zcharx.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/gs/psi/zcharx.c b/gs/psi/zcharx.c
index 25f07eba3..002480a4a 100644
--- a/gs/psi/zcharx.c
+++ b/gs/psi/zcharx.c
@@ -92,7 +92,7 @@ static int
moveshow(i_ctx_t *i_ctx_p, bool have_x, bool have_y)
{
os_ptr op = osp;
- gs_text_enum_t *penum;
+ gs_text_enum_t *penum = NULL;
int code = op_show_setup(i_ctx_p, op - 1);
int format;
uint i, size, widths_needed;
@@ -115,7 +115,8 @@ moveshow(i_ctx_t *i_ctx_p, bool have_x, bool have_y)
(have_y ? values : (float *)0),
size, imemory_local, &penum)) < 0) {
ifree_object(values, "moveshow");
- penum->text.x_widths = penum->text.y_widths = NULL;
+ if (penum) /* if there was an error, the text_enum may not have been allocated */
+ penum->text.x_widths = penum->text.y_widths = NULL;
return code;
}
if (CPSI_mode) {