DoubleToRational(): avoid casting NaN to uint32 (fixes #227)

This commit is contained in:
Even Rouault 2020-12-12 15:31:05 +01:00
parent 39d6c91ffd
commit 9a935c7e23
No known key found for this signature in database
GPG Key ID: 33EBBFC47B3DD87D

View File

@ -2826,7 +2826,8 @@ void DoubleToRational(double value, uint32 *num, uint32 *denom)
unsigned long long ullNum, ullDenom, ullNum2, ullDenom2;
/*-- Check for negative values. If so it is an error. */
if (value < 0) {
/* Test written that way to catch NaN */
if (!(value >= 0)) {
*num = *denom = 0;
TIFFErrorExt(0, "TIFFLib: DoubleToRational()", " Negative Value for Unsigned Rational given.");
return;