From 9a935c7e2350d3bd3d06fa53db58905fbae2dc63 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sat, 12 Dec 2020 15:31:05 +0100 Subject: [PATCH] DoubleToRational(): avoid casting NaN to uint32 (fixes #227) --- libtiff/tif_dirwrite.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libtiff/tif_dirwrite.c b/libtiff/tif_dirwrite.c index 952d107b..f481250e 100644 --- a/libtiff/tif_dirwrite.c +++ b/libtiff/tif_dirwrite.c @@ -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;