From b72508c8fce196cd031856574c202490be830649 Mon Sep 17 00:00:00 2001 From: Cristy Date: Fri, 19 Apr 2024 14:33:05 -0400 Subject: [PATCH] check for value < 0, ceil() not required (https://github.com/ImageMagick/ImageMagick/issues/6341) --- magick/image-private.h | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/magick/image-private.h b/magick/image-private.h index 07b083fe6..b371af9dd 100644 --- a/magick/image-private.h +++ b/magick/image-private.h @@ -78,14 +78,13 @@ static inline ssize_t CastDoubleToLong(const double x) { errno=ERANGE; return((ssize_t) MAGICK_SSIZE_MAX); - } - value=ceil(x); + } value=ceil(x); if (value < ((double) MAGICK_SSIZE_MIN+1)) { errno=ERANGE; return((ssize_t) MAGICK_SSIZE_MIN); } - return((ssize_t) x); + return((ssize_t) value); } static inline QuantumAny CastDoubleToQuantumAny(const double x) @@ -124,13 +123,12 @@ static inline size_t CastDoubleToUnsigned(const double x) errno=ERANGE; return((size_t) MAGICK_SIZE_MAX); } - value=ceil(x); - if (ceil(x) < 0.0) + if (value < 0.0) { errno=ERANGE; return(0); } - return((size_t) x); + return((size_t) value); } static inline double DegreesToRadians(const double degrees)