From 65a259a0258b2036b168cdeff6e9db434471225a Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Wed, 20 Feb 2019 15:15:50 +0000 Subject: [PATCH] prevent /0 in freq mask for very small masks see https://github.com/libvips/libvips/issues/1236 --- libvips/create/mask.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libvips/create/mask.c b/libvips/create/mask.c index 5d3739b6..66f8a197 100644 --- a/libvips/create/mask.c +++ b/libvips/create/mask.c @@ -58,8 +58,11 @@ vips_mask_point( VipsPoint *point, int x, int y ) { VipsMask *mask = VIPS_MASK( point ); VipsMaskClass *class = VIPS_MASK_GET_CLASS( point ); - int half_width = point->width / 2; - int half_height = point->height / 2; + + /* VIPS_MAX to prevent /0. + */ + int half_width = VIPS_MAX( point->width / 2, 1 ); + int half_height = VIPS_MAX( point->height / 2, 1 ); double result;