From f62a3f606db3163b85666a0b8997e52987c87e97 Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Fri, 28 Apr 2023 19:22:09 +0100 Subject: Ensure that we catch errors from gs_update_trans_marking_params --- base/gdevp14.c | 28 +++++++++++++++++++--------- base/gspaint.c | 4 +++- 2 files changed, 22 insertions(+), 10 deletions(-) (limited to 'base') diff --git a/base/gdevp14.c b/base/gdevp14.c index afa303ad8..ff7b24f1f 100644 --- a/base/gdevp14.c +++ b/base/gdevp14.c @@ -4457,9 +4457,11 @@ pdf14_fill_stroke_prestroke(gx_device* dev, gs_gstate* pgs, float stroke_alpha, } /* Cleanup after the stroke in fill-stroke */ -static void +static int pdf14_fill_stroke_poststroke(gx_device* dev, gs_gstate* pgs, float fill_alpha, bool op_ca_eq_CA) { + int code; + if (!op_ca_eq_CA) { /* Bug 703324 we need to reset the fill constant alpha in the graphics * state to the correct saved value. We also need to reset the 'opacity' member of the @@ -4468,9 +4470,13 @@ pdf14_fill_stroke_poststroke(gx_device* dev, gs_gstate* pgs, float fill_alpha, b * We therefore need to make sure it is set according to the current fill state. */ (void)gs_setfillconstantalpha(pgs, fill_alpha); - gs_update_trans_marking_params(pgs); + code = gs_update_trans_marking_params(pgs); + if (code < 0) + return code; pdf14_set_marking_params(dev, pgs); } + + return 0; } /* cleanup in fill-stroke */ @@ -4590,13 +4596,16 @@ pdf14_fill_stroke_path(gx_device *dev, const gs_gstate *cpgs, gx_path *ppath, global_index++; #endif if (group_needed) - pdf14_fill_stroke_poststroke(dev, pgs, fill_alpha, save_op_state); + code = pdf14_fill_stroke_poststroke(dev, pgs, fill_alpha, save_op_state); cleanup: if (group_needed) { + int code1; pgs->device = dev; /* This is needed due to the gs_trans calls */ - code = pdf14_fill_stroke_cleanup(dev, pgs, fill_alpha, stroke_alpha, blend_mode, + code1 = pdf14_fill_stroke_cleanup(dev, pgs, fill_alpha, stroke_alpha, blend_mode, save_op_state); + if (code1 < 0) + code = code1; pgs->device = curr_pgs_dev; } return code; @@ -8782,7 +8791,7 @@ pdf14_dev_spec_op(gx_device *pdev, int dev_spec_op, if (code < 0) goto cleanup; } - gs_update_trans_marking_params(pgs); + code = gs_update_trans_marking_params(pgs); break; case OP_FS_TRANS_PRESTROKE: @@ -8790,15 +8799,16 @@ pdf14_dev_spec_op(gx_device *pdev, int dev_spec_op, pdf14_fill_stroke_prestroke(pdev, pdf14_abuf->pgs, pdf14_abuf->stroke_alpha, pdf14_abuf->blend_mode, pdf14_abuf->op_ca_eq_CA); } - gs_update_trans_marking_params(pgs); + code = gs_update_trans_marking_params(pgs); break; case OP_FS_TRANS_POSTSTROKE: if (pdf14_abuf->group_needed) { - pdf14_fill_stroke_poststroke(pdev, pdf14_abuf->pgs, pdf14_abuf->fill_alpha, - pdf14_abuf->op_ca_eq_CA); + code = pdf14_fill_stroke_poststroke(pdev, pdf14_abuf->pgs, pdf14_abuf->fill_alpha, + pdf14_abuf->op_ca_eq_CA); } - gs_update_trans_marking_params(pgs); + if (code >= 0) + code = gs_update_trans_marking_params(pgs); /* fallthrough */ diff --git a/base/gspaint.c b/base/gspaint.c index 02f7a9bfa..30d78e0c6 100644 --- a/base/gspaint.c +++ b/base/gspaint.c @@ -240,7 +240,9 @@ alpha_buffer_init(gs_gstate * pgs, fixed extra_x, fixed extra_y, int alpha_bits, /* We may have to update the marking parameters if we have a pdf14 device as our target. Need to do while dev is still active in pgs */ if (dev_proc(dev, dev_spec_op)(dev, gxdso_is_pdf14_device, NULL, 0) > 0) { - gs_update_trans_marking_params(pgs); + int code = gs_update_trans_marking_params(pgs); + if (code < 0) + return code; } gs_make_mem_abuf_device(mdev, mem, dev, &log2_scale, alpha_bits, ibox.p.x << log2_scale.x, devn); -- cgit v1.2.1