Skip to content

Commit 44688e2

Browse files
committed
fix int overflow in vips_region_copy
this could cause crashes with very wide images, see: #1989
1 parent 75959ec commit 44688e2

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

libvips/iofuncs/region.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@
4848
* 9/6/19
4949
* - saner behaviour for vips_region_fetch() if the request is partly
5050
* outside the image
51+
* 22/2/21 f1ac
52+
* - fix int overflow in vips_region_copy(), could cause crashes with
53+
* very wide images
5154
*/
5255

5356
/*
@@ -1048,12 +1051,13 @@ void
10481051
vips_region_copy( VipsRegion *reg,
10491052
VipsRegion *dest, const VipsRect *r, int x, int y )
10501053
{
1051-
int z;
1052-
int len = VIPS_IMAGE_SIZEOF_PEL( reg->im ) * r->width;
1054+
size_t len = VIPS_IMAGE_SIZEOF_PEL( reg->im ) * r->width;
10531055
VipsPel *p = VIPS_REGION_ADDR( reg, r->left, r->top );
10541056
VipsPel *q = VIPS_REGION_ADDR( dest, x, y );
1055-
int plsk = VIPS_REGION_LSKIP( reg );
1056-
int qlsk = VIPS_REGION_LSKIP( dest );
1057+
size_t plsk = VIPS_REGION_LSKIP( reg );
1058+
size_t qlsk = VIPS_REGION_LSKIP( dest );
1059+
1060+
int z;
10571061

10581062
#ifdef DEBUG
10591063
/* Find the area we will write to in dest.

0 commit comments

Comments
 (0)