From 42c0918f239775be2b1774eb89fadb1577b5df6e Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Fri, 10 Mar 2023 15:19:27 +0000 Subject: Bug 706351 (maybe): Fix error seen when testing display dev in api_test Chunky separations were SEGVing due to a the device proc for fill_rectangle_hl_color not being setup. Planar separations were buffer overflowing due to a short allocation for the bitmap due to unknown number of separations. --- devices/gdevdsp.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'devices') diff --git a/devices/gdevdsp.c b/devices/gdevdsp.c index e279d5874..217d9c8ac 100644 --- a/devices/gdevdsp.c +++ b/devices/gdevdsp.c @@ -1843,6 +1843,9 @@ display_set_separations(gx_device_display *dev) unsigned int c, m, y, k; gx_device_display *head = dev; + if (num_comp > GX_DEVICE_COLOR_MAX_COMPONENTS) + num_comp = GX_DEVICE_COLOR_MAX_COMPONENTS; + while(head->parent) head = (gx_device_display *)head->parent; @@ -2218,11 +2221,16 @@ display_set_color_format(gx_device_display *ddev, int nFormat) return_error(gs_error_rangecheck); if (ddev->is_planar) { - int n = ddev->devn_params.num_std_colorant_names + ddev->devn_params.separations.num_separations; - if (n == 0) - n = GS_CLIENT_COLOR_MAX_COMPONENTS; - if (n > GS_CLIENT_COLOR_MAX_COMPONENTS) + int n; + if (ddev->devn_params.separations.num_separations == 0) n = GS_CLIENT_COLOR_MAX_COMPONENTS; + else { + n = ddev->devn_params.num_std_colorant_names + ddev->devn_params.separations.num_separations; + if (n == 0) + n = GS_CLIENT_COLOR_MAX_COMPONENTS; + if (n > GS_CLIENT_COLOR_MAX_COMPONENTS) + n = GS_CLIENT_COLOR_MAX_COMPONENTS; + } bpp = n * 8; set_color_info(&dci, DISPLAY_MODEL_SEP, n, GS_CLIENT_COLOR_MAX_COMPONENTS, bpp, maxvalue, maxvalue); -- cgit v1.2.1