Skip to content

Commit

Permalink
check for value < 0, ceil() not required (ImageMagick/ImageMagick#6341)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cristy committed Apr 19, 2024
1 parent 75ebd99 commit b72508c
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions magick/image-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit b72508c

Please sign in to comment.