diff options
author | Robin Watts <Robin.Watts@artifex.com> | 2011-07-28 17:08:58 +0100 |
---|---|---|
committer | Chris Liddell <chris.liddell@artifex.com> | 2011-07-28 18:18:11 +0100 |
commit | 0f6629c581fb56ca33fb7ec57d757ea96f236887 (patch) | |
tree | 65c72b13c2e91e7eb3ce3a45b23a666b2e138c9c | |
parent | f31edd69e23236fbae4b986883df8e0f43f15af6 (diff) |
Check for failure to allocate icclink in shading.
When calling shade_init_fill_state, check for a return code to indicate
failure. Trigger this case when an attempt to allocate an icclink
fails.
No cluster differences expected.
-rw-r--r-- | gs/base/gxshade.c | 7 | ||||
-rw-r--r-- | gs/base/gxshade.h | 6 | ||||
-rw-r--r-- | gs/base/gxshade1.c | 16 | ||||
-rw-r--r-- | gs/base/gxshade4.c | 23 |
4 files changed, 35 insertions, 17 deletions
diff --git a/gs/base/gxshade.c b/gs/base/gxshade.c index b7588a063..5df10b538 100644 --- a/gs/base/gxshade.c +++ b/gs/base/gxshade.c @@ -308,7 +308,7 @@ shade_next_vertex(shade_coord_stream_t * cs, shading_vertex_t * vertex, patch_co /* ================ Shading rendering ================ */ /* Initialize the common parts of the recursion state. */ -void +int shade_init_fill_state(shading_fill_state_t * pfs, const gs_shading_t * psh, gx_device * dev, gs_imager_state * pis) { @@ -390,6 +390,8 @@ top: if (pcs->cmm_icc_profile_data != NULL) { pfs->icclink = gsicc_get_link(pis, pis->trans_device, pcs, NULL, &rendering_params, pis->memory, false); + if (pfs->icclink == NULL) + return gs_error_VMerror; } else { if (pcs->icc_equivalent != NULL ) { /* We have a PS equivalent ICC profile. We may need to go @@ -397,10 +399,13 @@ top: pfs->icclink = gsicc_get_link(pis, pis->trans_device, pcs->icc_equivalent, NULL, &rendering_params, pis->memory, false); + if (pfs->icclink == NULL) + return gs_error_VMerror; } else { pfs->icclink = NULL; } } + return 0; } /* Fill one piece of a shading. */ diff --git a/gs/base/gxshade.h b/gs/base/gxshade.h index 3d28b9831..9a6817830 100644 --- a/gs/base/gxshade.h +++ b/gs/base/gxshade.h @@ -204,9 +204,9 @@ typedef struct shading_fill_state_s { } shading_fill_state_t; /* Initialize the common parts of the recursion state. */ -void shade_init_fill_state(shading_fill_state_t * pfs, - const gs_shading_t * psh, gx_device * dev, - gs_imager_state * pis); +int shade_init_fill_state(shading_fill_state_t * pfs, + const gs_shading_t * psh, gx_device * dev, + gs_imager_state * pis); /* Fill one piece of a shading. */ #ifndef gx_device_color_DEFINED diff --git a/gs/base/gxshade1.c b/gs/base/gxshade1.c index 10ca85300..5c1e71937 100644 --- a/gs/base/gxshade1.c +++ b/gs/base/gxshade1.c @@ -130,7 +130,9 @@ gs_shading_Fb_fill_rectangle(const gs_shading_t * psh0, const gs_rect * rect, float x[2], y[2]; Fb_fill_state_t state; - shade_init_fill_state((shading_fill_state_t *) & state, psh0, dev, pis); + code = shade_init_fill_state((shading_fill_state_t *) & state, psh0, dev, pis); + if (code < 0) + return code; state.psh = psh; /****** HACK FOR FIXED-POINT MATRIX MULTIPLY ******/ gs_currentmatrix((gs_state *) pis, &save_ctm); @@ -227,7 +229,9 @@ gs_shading_A_fill_rectangle_aux(const gs_shading_t * psh0, const gs_rect * rect, int code; state.psh = psh; - shade_init_fill_state((shading_fill_state_t *)&pfs1, psh0, dev, pis); + code = shade_init_fill_state((shading_fill_state_t *)&pfs1, psh0, dev, pis); + if (code < 0) + return code; pfs1.Function = pfn; pfs1.rect = *clip_rect; code = init_patch_fill_state(&pfs1); @@ -285,9 +289,9 @@ gs_shading_A_fill_rectangle_aux(const gs_shading_t * psh0, const gs_rect * rect, state.t0 = state.t1 = t1 * dd + d0; code = A_fill_region(&state, &pfs1); } + if (pfs1.icclink != NULL) gsicc_release_link(pfs1.icclink); if (term_patch_fill_state(&pfs1)) return_error(gs_error_unregistered); /* Must not happen. */ - if (pfs1.icclink != NULL) gsicc_release_link(pfs1.icclink); return code; } @@ -1163,7 +1167,9 @@ gs_shading_R_fill_rectangle_aux(const gs_shading_t * psh0, const gs_rect * rect, if (r0 == 0 && r1 == 0) return 0; /* PLRM requires to paint nothing. */ - shade_init_fill_state((shading_fill_state_t *)&pfs1, psh0, dev, pis); + code = shade_init_fill_state((shading_fill_state_t *)&pfs1, psh0, dev, pis); + if (code < 0) + return code; pfs1.Function = psh->params.Function; code = init_patch_fill_state(&pfs1); if (code < 0) { @@ -1221,9 +1227,9 @@ gs_shading_R_fill_rectangle_aux(const gs_shading_t * psh0, const gs_rect * rect, if (code >= 0 && (span_type & 8)) code = R_extensions(&pfs1, psh, rect, d0, d1, false, psh->params.Extend[1]); } + if (pfs1.icclink != NULL) gsicc_release_link(pfs1.icclink); if (term_patch_fill_state(&pfs1)) return_error(gs_error_unregistered); /* Must not happen. */ - if (pfs1.icclink != NULL) gsicc_release_link(pfs1.icclink); return code; } diff --git a/gs/base/gxshade4.c b/gs/base/gxshade4.c index f0875d5a4..dcdba3498 100644 --- a/gs/base/gxshade4.c +++ b/gs/base/gxshade4.c @@ -38,8 +38,11 @@ mesh_init_fill_state(mesh_fill_state_t * pfs, const gs_shading_mesh_t * psh, const gs_fixed_rect * rect_clip, gx_device * dev, gs_imager_state * pis) { - shade_init_fill_state((shading_fill_state_t *) pfs, - (const gs_shading_t *)psh, dev, pis); + int code; + code = shade_init_fill_state((shading_fill_state_t *) pfs, + (const gs_shading_t *)psh, dev, pis); + if (code < 0) + return code; pfs->pshm = psh; pfs->rect = *rect_clip; return 0; @@ -104,8 +107,10 @@ gs_shading_FfGt_fill_rectangle(const gs_shading_t * psh0, const gs_rect * rect, vd_set_scale(0.01); vd_set_origin(0, 0); } - shade_init_fill_state((shading_fill_state_t *)&pfs, - (const gs_shading_t *)psh, dev, pis); + code = shade_init_fill_state((shading_fill_state_t *)&pfs, + (const gs_shading_t *)psh, dev, pis); + if (code < 0) + return code; pfs.Function = pshm->params.Function; pfs.rect = *rect_clip; code = init_patch_fill_state(&pfs); @@ -152,11 +157,11 @@ v2: if ((code = Gt_next_vertex(pshm, &cs, &vc, cc)) < 0) if (VD_TRACE_TRIANGLE_PATCH && vd_allowed('s')) vd_release_dc; release_colors(&pfs, pfs.color_stack, 3); + if (pfs.icclink != NULL) gsicc_release_link(pfs.icclink); if (term_patch_fill_state(&pfs)) return_error(gs_error_unregistered); /* Must not happen. */ if (!cs.is_eod(&cs)) return_error(gs_error_rangecheck); - if (pfs.icclink != NULL) gsicc_release_link(pfs.icclink); return code; } @@ -183,8 +188,10 @@ gs_shading_LfGt_fill_rectangle(const gs_shading_t * psh0, const gs_rect * rect, vd_set_scale(0.01); vd_set_origin(0, 0); } - shade_init_fill_state((shading_fill_state_t *)&pfs, - (const gs_shading_t *)psh, dev, pis); + code = shade_init_fill_state((shading_fill_state_t *)&pfs, + (const gs_shading_t *)psh, dev, pis); + if (code < 0) + return code; pfs.Function = pshm->params.Function; pfs.rect = *rect_clip; code = init_patch_fill_state(&pfs); @@ -250,8 +257,8 @@ out: gs_free_object(pis->memory, color_buffer, "gs_shading_LfGt_render"); gs_free_object(pis->memory, color_buffer_ptrs, "gs_shading_LfGt_render"); release_colors(&pfs, pfs.color_stack, 1); + if (pfs.icclink != NULL) gsicc_release_link(pfs.icclink); if (term_patch_fill_state(&pfs)) return_error(gs_error_unregistered); /* Must not happen. */ - if (pfs.icclink != NULL) gsicc_release_link(pfs.icclink); return code; } |