summaryrefslogtreecommitdiff
path: root/draw/draw_blend.c
diff options
context:
space:
mode:
authorRobin Watts <robin@peeves.(none)>2012-06-11 11:49:31 -0700
committerRobin Watts <robin.watts@artifex.com>2012-06-11 19:55:54 +0100
commit4fddb35e247a2d81b9b78ca3543b97da9e9fce45 (patch)
treefe87bc8ab4351a8cb5a9892c83ab63837bb109b5 /draw/draw_blend.c
parent120dabdf30be66b5d17f4c59862907bb5d176e27 (diff)
downloadmupdf-4fddb35e247a2d81b9b78ca3543b97da9e9fce45.tar.xz
Fix Bug 693102: Overflows in large pixmap indexing.
When we allocate a pixmap > 2G, but < 4G, the index into that pixmap, when calculated as an int can be negative. Fix this with various casts to unsigned int. If we ever move to support >4G images we'll need to rejig the casting to cast each part of the element to ptrdiff_t first.
Diffstat (limited to 'draw/draw_blend.c')
-rw-r--r--draw/draw_blend.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/draw/draw_blend.c b/draw/draw_blend.c
index 7c74df79..8a751c08 100644
--- a/draw/draw_blend.c
+++ b/draw/draw_blend.c
@@ -598,14 +598,14 @@ fz_blend_pixmap(fz_pixmap *dst, fz_pixmap *src, int alpha, int blendmode, int is
h = bbox.y1 - bbox.y0;
n = src->n;
- sp = src->samples + ((y - src->y) * src->w + (x - src->x)) * n;
- dp = dst->samples + ((y - dst->y) * dst->w + (x - dst->x)) * n;
+ sp = src->samples + (unsigned int)(((y - src->y) * src->w + (x - src->x)) * n);
+ dp = dst->samples + (unsigned int)(((y - dst->y) * dst->w + (x - dst->x)) * n);
assert(src->n == dst->n);
if (!isolated)
{
- unsigned char *hp = shape->samples + (y - shape->y) * shape->w + (x - shape->x);
+ unsigned char *hp = shape->samples + (unsigned int)((y - shape->y) * shape->w + (x - shape->x));
while (h--)
{