From 2c9c8b75de448ae0ee1394f672eb0baa4c7dd57a Mon Sep 17 00:00:00 2001 From: Sebastian Rasmussen Date: Sun, 12 Aug 2018 16:56:57 +0800 Subject: Bug 698898: Always pop draw stack in case of exception. When fz_draw_clip_image_mask() calls fz_get_pixmap_from_image() may throw an exception, in this case beacuse a predicted image has an unsupported number of components (1, 2, 4, 8 and 16 are supported, but 6 is not). When this happens the recently pushed stack element is never popped, which later trips an assert() in fz_draw_end_group() at a later stage. By moving the call to fz_get_pixmap_from_image() inside fz_try the stack will be popped, thus avoiding triggering the assert(). This also requires the pixmap variable to be fz_var()ed because it changes inside the fz_try-block. --- source/fitz/draw-device.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/fitz/draw-device.c b/source/fitz/draw-device.c index d1b6d54c..1bfb9577 100644 --- a/source/fitz/draw-device.c +++ b/source/fitz/draw-device.c @@ -1950,6 +1950,8 @@ fz_draw_clip_image_mask(fz_context *ctx, fz_device *devp, fz_image *image, fz_ma fz_colorspace *model = state->dest->colorspace; fz_irect clip; + fz_var(pixmap); + if (dev->top == 0 && dev->resolve_spots) state = push_group_for_separations(ctx, dev, fz_default_color_params(ctx)/* FIXME */, dev->default_cs); @@ -1979,10 +1981,10 @@ fz_draw_clip_image_mask(fz_context *ctx, fz_device *devp, fz_image *image, fz_ma bbox = fz_intersect_irect(bbox, fz_irect_from_rect(tscissor)); } - pixmap = fz_get_pixmap_from_image(ctx, image, NULL, &local_ctm, &dx, &dy); - fz_try(ctx) { + pixmap = fz_get_pixmap_from_image(ctx, image, NULL, &local_ctm, &dx, &dy); + state[1].mask = fz_new_pixmap_with_bbox(ctx, NULL, bbox, NULL, 1); fz_clear_pixmap(ctx, state[1].mask); -- cgit v1.2.3