From 2fb81b8ed6a4a6b2385f3efbb0412f24f80163c4 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Wed, 20 Feb 2019 15:00:00 +0000 Subject: [PATCH] prevent /0 in eye for width/height 1 see https://github.com/libvips/libvips/issues/1236 --- libvips/create/eye.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libvips/create/eye.c b/libvips/create/eye.c index c348f180..1544fbe9 100644 --- a/libvips/create/eye.c +++ b/libvips/create/eye.c @@ -77,8 +77,13 @@ vips_eye_point( VipsPoint *point, int x, int y ) { VipsEye *eye = (VipsEye *) point; - double c = eye->factor * VIPS_PI / (2 * (point->width - 1)); - double h = ((point->height - 1) * (point->height - 1)); + /* VIPS_MAX to prevent /0. + */ + int max_x = VIPS_MAX( point->width - 1, 1 ); + int max_y = VIPS_MAX( point->height - 1, 1 ); + + double c = eye->factor * VIPS_PI / (2 * max_x); + double h = max_y * max_y; return( y * y * cos( c * x * x ) / h ); }