summaryrefslogtreecommitdiff
path: root/draw/draw_device.c
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2012-01-06 11:28:27 +0000
committerRobin Watts <robin@ghostscript.com>2012-01-06 13:49:24 +0000
commit4cebdd8f39343543ba6dc5230348e9c3d7f54553 (patch)
tree51af794278b5f23a7e737a099a11e198b5547210 /draw/draw_device.c
parent78179a6f0cdbf84ca2344e1ca22c04ae6c701364 (diff)
downloadmupdf-4cebdd8f39343543ba6dc5230348e9c3d7f54553.tar.xz
draw_device; device state stack handling fixes.
Only create a shape if we need to. Correctly cleanup, thus avoiding a double free of mask later on. Thanks to Zeniko for spotting these.
Diffstat (limited to 'draw/draw_device.c')
-rw-r--r--draw/draw_device.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/draw/draw_device.c b/draw/draw_device.c
index d3695073..6b1710d6 100644
--- a/draw/draw_device.c
+++ b/draw/draw_device.c
@@ -763,8 +763,11 @@ fz_draw_fill_shade(fz_device *devp, fz_shade *shade, fz_matrix ctm, float alpha)
{
dest = fz_new_pixmap_with_rect(dev->ctx, state->dest->colorspace, bbox);
fz_clear_pixmap(dest);
- shape = fz_new_pixmap_with_rect(dev->ctx, NULL, bbox);
- fz_clear_pixmap(shape);
+ if (shape)
+ {
+ shape = fz_new_pixmap_with_rect(dev->ctx, NULL, bbox);
+ fz_clear_pixmap(shape);
+ }
}
if (shade->use_background)
@@ -1222,11 +1225,15 @@ fz_draw_end_mask(fz_device *devp)
#endif
/* convert to alpha mask */
temp = fz_alpha_from_gray(dev->ctx, state[1].dest, luminosity);
- fz_drop_pixmap(dev->ctx, state[1].mask);
- state[1].mask = NULL;
+ if (state[1].dest != state[0].dest)
+ fz_drop_pixmap(dev->ctx, state[1].dest);
+ state[1].dest = NULL;
if (state[1].shape != state[0].shape)
fz_drop_pixmap(dev->ctx, state[1].shape);
state[1].shape = NULL;
+ if (state[1].mask != state[0].mask)
+ fz_drop_pixmap(dev->ctx, state[1].mask);
+ state[1].mask = NULL;
/* create new dest scratch buffer */
bbox = fz_bound_pixmap(temp);