summaryrefslogtreecommitdiff
path: root/base
diff options
context:
space:
mode:
authorChris Liddell <chris.liddell@artifex.com>2017-06-29 11:20:09 +0100
committerChris Liddell <chris.liddell@artifex.com>2017-06-30 14:08:55 +0100
commit0b7fa9293f43dce8aea028e4d2b32da1d8fc18c8 (patch)
treec23031e84ab58a1826067da0ce4b46396b1bb231 /base
parentd592ee18a9168b1190bc7f7a1426b41fa6d508af (diff)
downloadghostpdl-0b7fa9293f43dce8aea028e4d2b32da1d8fc18c8.tar.gz
Add error checking for gs_colorspace_set_icc_equivalent()
Diffstat (limited to 'base')
-rw-r--r--base/gscdevn.c11
-rw-r--r--base/gsciemap.c11
-rw-r--r--base/gscolor2.c30
-rw-r--r--base/gscsepr.c6
-rw-r--r--base/gstrans.c2
-rw-r--r--base/gxcmap.c16
-rw-r--r--base/gxipixel.c4
-rw-r--r--base/gxiscale.c2
-rw-r--r--base/gxshade.c5
9 files changed, 53 insertions, 34 deletions
diff --git a/base/gscdevn.c b/base/gscdevn.c
index cc2e5e51c..6b8108ec9 100644
--- a/base/gscdevn.c
+++ b/base/gscdevn.c
@@ -353,7 +353,7 @@ gx_concrete_space_DeviceN(const gs_color_space * pcs,
/* Need to handle PS CIE space */
if (gs_color_space_is_PSCIE(pcs->base_space)) {
if (pcs->base_space->icc_equivalent == NULL) {
- gs_colorspace_set_icc_equivalent(pcs->base_space,
+ (void)gs_colorspace_set_icc_equivalent(pcs->base_space,
&is_lab, pgs->memory);
}
return (pcs->base_space->icc_equivalent);
@@ -469,13 +469,16 @@ gx_concretize_DeviceN(const gs_client_color * pc, const gs_color_space * pcs,
rescale_cie_colors(pacs, &cc);
/* If we have not yet created the profile do that now */
if (pacs->icc_equivalent == NULL) {
- gs_colorspace_set_icc_equivalent(pacs, &(is_lab), pgs->memory);
+ code = gs_colorspace_set_icc_equivalent(pacs, &(is_lab), pgs->memory);
+ if (code < 0)
+ return code;
}
/* Use the ICC equivalent color space */
pacs = pacs->icc_equivalent;
}
- if (pacs->cmm_icc_profile_data->data_cs == gsCIELAB ||
- pacs->cmm_icc_profile_data->islab) {
+ if (pacs->cmm_icc_profile_data &&
+ (pacs->cmm_icc_profile_data->data_cs == gsCIELAB ||
+ pacs->cmm_icc_profile_data->islab)) {
/* Get the data in a form that is concrete for the CMM */
cc.paint.values[0] /= 100.0;
cc.paint.values[1] = (cc.paint.values[1]+128)/255.0;
diff --git a/base/gsciemap.c b/base/gsciemap.c
index e0c87eb5e..ad75f9852 100644
--- a/base/gsciemap.c
+++ b/base/gsciemap.c
@@ -848,6 +848,7 @@ gs_colorspace_set_icc_equivalent(gs_color_space *pcs, bool *islab,
{
gs_color_space_index color_space_index = gs_color_space_get_index(pcs);
gs_color_space *picc_cs;
+ int code = 0;
*islab = false; /* For non CIEABC cases */
if (pcs->icc_equivalent != NULL || !gs_color_space_is_PSCIE(pcs))
@@ -855,22 +856,22 @@ gs_colorspace_set_icc_equivalent(gs_color_space *pcs, bool *islab,
switch( color_space_index ) {
case gs_color_space_index_CIEDEFG:
- gx_ciedefg_to_icc(&picc_cs, pcs, memory->stable_memory);
+ code = gx_ciedefg_to_icc(&picc_cs, pcs, memory->stable_memory);
break;
case gs_color_space_index_CIEDEF:
- gx_ciedef_to_icc(&picc_cs, pcs, memory->stable_memory);
+ code = gx_ciedef_to_icc(&picc_cs, pcs, memory->stable_memory);
break;
case gs_color_space_index_CIEABC:
- gx_cieabc_to_icc(&picc_cs, pcs, islab, memory->stable_memory);
+ code = gx_cieabc_to_icc(&picc_cs, pcs, islab, memory->stable_memory);
break;
case gs_color_space_index_CIEA:
- gx_ciea_to_icc(&picc_cs, pcs, memory->stable_memory);
+ code = gx_ciea_to_icc(&picc_cs, pcs, memory->stable_memory);
break;
default:
/* do nothing. Sould never happen */
break;
}
- return 0;
+ return code;
}
/* Call the remap_finish procedure in the joint_caches structure. */
diff --git a/base/gscolor2.c b/base/gscolor2.c
index 67b36a786..1be0cf2e2 100644
--- a/base/gscolor2.c
+++ b/base/gscolor2.c
@@ -484,7 +484,7 @@ gx_concrete_space_Indexed(const gs_color_space * pcs,
if (gs_color_space_is_PSCIE(pcs->base_space)) {
if (pcs->base_space->icc_equivalent == NULL) {
- gs_colorspace_set_icc_equivalent(pcs->base_space,
+ (void)gs_colorspace_set_icc_equivalent(pcs->base_space,
&is_lab, pgs->memory);
}
return (pcs->base_space->icc_equivalent);
@@ -524,19 +524,21 @@ gs_color_select_t select)
return code;
pconcs = cs_concrete_space(pcs, pgs);
- /* Now see if we can do the named color replacement */
- mapped = gx_remap_named_color(&cc, pconcs, pdc, pgs, dev, select);
-
- if (!mapped) {
- /* Named color remap failed perhaps due to colorant not found. Do the
- old approach of concretize of the base space and remap concrete color */
- const gs_color_space *pbcs =
- (const gs_color_space *)pcs->base_space;
-
- code = (*pbcs->type->concretize_color) (&cc, pbcs, conc, pgs, dev);
- if (code < 0)
- return code;
- code = (*pconcs->type->remap_concrete_color)(conc, pconcs, pdc, pgs, dev, select);
+ if (pconcs) {
+ /* Now see if we can do the named color replacement */
+ mapped = gx_remap_named_color(&cc, pconcs, pdc, pgs, dev, select);
+
+ if (!mapped) {
+ /* Named color remap failed perhaps due to colorant not found. Do the
+ old approach of concretize of the base space and remap concrete color */
+ const gs_color_space *pbcs =
+ (const gs_color_space *)pcs->base_space;
+
+ code = (*pbcs->type->concretize_color) (&cc, pbcs, conc, pgs, dev);
+ if (code < 0)
+ return code;
+ code = (*pconcs->type->remap_concrete_color)(conc, pconcs, pdc, pgs, dev, select);
+ }
}
/* Save original color space and color info into dev color */
diff --git a/base/gscsepr.c b/base/gscsepr.c
index d042940b0..368330310 100644
--- a/base/gscsepr.c
+++ b/base/gscsepr.c
@@ -100,7 +100,7 @@ gx_concrete_space_Separation(const gs_color_space * pcs,
/* Need to handle PS CIE space */
if (gs_color_space_is_PSCIE(pcs->base_space)) {
if (pcs->base_space->icc_equivalent == NULL) {
- gs_colorspace_set_icc_equivalent(pcs->base_space,
+ (void)gs_colorspace_set_icc_equivalent(pcs->base_space,
&is_lab, pgs->memory);
}
return (pcs->base_space->icc_equivalent);
@@ -350,7 +350,9 @@ gx_concretize_Separation(const gs_client_color *pc, const gs_color_space *pcs,
rescale_cie_colors(pacs, &cc);
/* If we have not yet created the profile do that now */
if (pacs->icc_equivalent == NULL) {
- gs_colorspace_set_icc_equivalent(pacs, &(is_lab), pgs->memory);
+ code = gs_colorspace_set_icc_equivalent(pacs, &(is_lab), pgs->memory);
+ if (code < 0)
+ return code;
}
/* Use the ICC equivalent color space */
pacs = pacs->icc_equivalent;
diff --git a/base/gstrans.c b/base/gstrans.c
index 24e02c2c2..94df2d354 100644
--- a/base/gstrans.c
+++ b/base/gstrans.c
@@ -248,6 +248,8 @@ gs_begin_transparency_group(gs_gstate *pgs,
blend_color_space = gs_currentcolorspace_inline(pgs);
} else {
blend_color_space = cs_concrete_space(blend_color_space, pgs);
+ if (!blend_color_space)
+ return_error(gs_error_undefined);
}
/* Note that if the /CS parameter was NOT present in the push
of the transparency group, then we must actually inherent
diff --git a/base/gxcmap.c b/base/gxcmap.c
index f36dd1741..191eee326 100644
--- a/base/gxcmap.c
+++ b/base/gxcmap.c
@@ -727,13 +727,17 @@ gx_default_remap_color(const gs_client_color * pcc, const gs_color_space * pcs,
if (code < 0)
return code;
pconcs = cs_concrete_space(pcs, pgs);
- code = (*pconcs->type->remap_concrete_color)(conc, pconcs, pdc, pgs, dev, select);
+ if (pconcs) {
+ code = (*pconcs->type->remap_concrete_color)(conc, pconcs, pdc, pgs, dev, select);
- /* Save original color space and color info into dev color */
- i = any_abs(i);
- for (i--; i >= 0; i--)
- pdc->ccolor.paint.values[i] = pcc->paint.values[i];
- pdc->ccolor_valid = true;
+ /* Save original color space and color info into dev color */
+ i = any_abs(i);
+ for (i--; i >= 0; i--)
+ pdc->ccolor.paint.values[i] = pcc->paint.values[i];
+ pdc->ccolor_valid = true;
+ }
+ else
+ code = gs_note_error(gs_error_undefined);
return code;
}
diff --git a/base/gxipixel.c b/base/gxipixel.c
index 4eb654844..ab205bc51 100644
--- a/base/gxipixel.c
+++ b/base/gxipixel.c
@@ -636,8 +636,10 @@ gx_image_enum_begin(gx_device * dev, const gs_gstate * pgs,
is not yet set, go ahead and handle that now. It may already
be done due to the above init_colors which may go through remap. */
if (gs_color_space_is_PSCIE(pcs) && pcs->icc_equivalent == NULL) {
- gs_colorspace_set_icc_equivalent((gs_color_space *)pcs, &(penum->icc_setup.is_lab),
+ code = gs_colorspace_set_icc_equivalent((gs_color_space *)pcs, &(penum->icc_setup.is_lab),
pgs->memory);
+ if (code < 0)
+ return code;
if (penum->icc_setup.is_lab) {
/* Free what ever profile was created and use the icc manager's
cielab profile */
diff --git a/base/gxiscale.c b/base/gxiscale.c
index 8bdba3a95..9e73ce444 100644
--- a/base/gxiscale.c
+++ b/base/gxiscale.c
@@ -886,7 +886,7 @@ static int handle_colors(gx_image_enum *penum, const frac *psrc, int spp_decode,
pactual_cs = pcs;
}
pconcs = cs_concrete_space(pactual_cs, pgs);
- if (pconcs->cmm_icc_profile_data != NULL) {
+ if (pconcs && pconcs->cmm_icc_profile_data != NULL) {
device_color = false;
} else {
device_color = (pconcs == pactual_cs);
diff --git a/base/gxshade.c b/base/gxshade.c
index ded1bb857..4aa37de1c 100644
--- a/base/gxshade.c
+++ b/base/gxshade.c
@@ -320,6 +320,7 @@ shade_init_fill_state(shading_fill_state_t * pfs, const gs_shading_t * psh,
float max_error = min(pgs->smoothness, MAX_SMOOTHNESS);
bool is_lab;
bool cs_lin_test;
+ int code;
/*
* There's no point in trying to achieve smoothness beyond what
@@ -383,7 +384,9 @@ top:
/* If the CS is PS based and we have not yet converted to the ICC form
then go ahead and do that now */
if (gs_color_space_is_PSCIE(pcs) && pcs->icc_equivalent == NULL) {
- gs_colorspace_set_icc_equivalent((gs_color_space *)pcs, &(is_lab), pgs->memory);
+ code = gs_colorspace_set_icc_equivalent((gs_color_space *)pcs, &(is_lab), pgs->memory);
+ if (code < 0)
+ return code;
}
rendering_params.black_point_comp = pgs->blackptcomp;
rendering_params.graphics_type_tag = GS_PATH_TAG;