summaryrefslogtreecommitdiff
path: root/source/fitz/draw-device.c
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2014-05-27 18:11:07 +0100
committerRobin Watts <robin.watts@artifex.com>2014-05-28 20:49:04 +0100
commite7bd6babd4b6567db153806eb928591f2b26f4e2 (patch)
tree67b377b3164ba2653ca050422cdc5c513120a701 /source/fitz/draw-device.c
parent165975f819d6aa44c9d22576b3d913c86b90fa11 (diff)
downloadmupdf-e7bd6babd4b6567db153806eb928591f2b26f4e2.tar.xz
Further fix for Bug 695260: Cope with out of memory in fz_draw_end_mask
If we hit an out of memory error in fz_draw_end_mask, then pop the stack, and rethrow. Ensure that the generic device code catches this error and sets the error_depth to 1 so that the final pop is ignored.
Diffstat (limited to 'source/fitz/draw-device.c')
-rw-r--r--source/fitz/draw-device.c35
1 files changed, 21 insertions, 14 deletions
diff --git a/source/fitz/draw-device.c b/source/fitz/draw-device.c
index 73a8b585..c5354e61 100644
--- a/source/fitz/draw-device.c
+++ b/source/fitz/draw-device.c
@@ -1478,23 +1478,30 @@ fz_draw_end_mask(fz_device *devp)
fz_drop_pixmap(dev->ctx, state[1].mask);
state[1].mask = NULL;
- /* create new dest scratch buffer */
- fz_pixmap_bbox(ctx, temp, &bbox);
- dest = fz_new_pixmap_with_bbox(dev->ctx, state->dest->colorspace, &bbox);
- fz_clear_pixmap(dev->ctx, dest);
+ fz_try(ctx)
+ {
+ /* create new dest scratch buffer */
+ fz_pixmap_bbox(ctx, temp, &bbox);
+ dest = fz_new_pixmap_with_bbox(dev->ctx, state->dest->colorspace, &bbox);
+ fz_clear_pixmap(dev->ctx, dest);
- /* push soft mask as clip mask */
- state[1].mask = temp;
- state[1].dest = dest;
- state[1].blendmode |= FZ_BLEND_ISOLATED;
- /* If we have a shape, then it'll need to be masked with the
- * clip mask when we pop. So create a new shape now. */
- if (state[0].shape)
+ /* push soft mask as clip mask */
+ state[1].mask = temp;
+ state[1].dest = dest;
+ state[1].blendmode |= FZ_BLEND_ISOLATED;
+ /* If we have a shape, then it'll need to be masked with the
+ * clip mask when we pop. So create a new shape now. */
+ if (state[0].shape)
+ {
+ state[1].shape = fz_new_pixmap_with_bbox(dev->ctx, NULL, &bbox);
+ fz_clear_pixmap(dev->ctx, state[1].shape);
+ }
+ state[1].scissor = bbox;
+ }
+ fz_catch(ctx)
{
- state[1].shape = fz_new_pixmap_with_bbox(dev->ctx, NULL, &bbox);
- fz_clear_pixmap(dev->ctx, state[1].shape);
+ emergency_pop_stack(dev, state);
}
- state[1].scissor = bbox;
}
static void