diff options
Diffstat (limited to 'MagickCore/image-private.h')
-rw-r--r-- | MagickCore/image-private.h | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/MagickCore/image-private.h b/MagickCore/image-private.h index 6cd48c2d0..b17823b1b 100644 --- a/MagickCore/image-private.h +++ b/MagickCore/image-private.h @@ -1,5 +1,5 @@ /* - Copyright 1999-2020 ImageMagick Studio LLC, a non-profit organization + Copyright 1999-2021 ImageMagick Studio LLC, a non-profit organization dedicated to making software imaging solutions freely available. You may not use this file except in compliance with the License. You may @@ -50,6 +50,17 @@ extern "C" { #define UndefinedCompressionQuality 0UL #define UndefinedTicksPerSecond 100L +static inline ssize_t CastDoubleToLong(const double value) +{ + if (IsNaN(value) != 0) + return(0); + if (value > (double) LONG_MAX) + return((ssize_t) LONG_MAX); + if (value < (double) LONG_MIN) + return((ssize_t) LONG_MIN); + return((ssize_t) value); +} + static inline double DegreesToRadians(const double degrees) { return((double) (MagickPI*degrees/180.0)); |