check for NaN etc. in XYZ2sRGB

we were not checking for Inf, NaN etc. and this could cause array
indexes to go out of range
This commit is contained in:
John Cupitt 2012-12-11 12:28:25 +00:00
parent 0274a36863
commit 77ec00b495
1 changed files with 13 additions and 0 deletions

View File

@ -264,6 +264,19 @@ vips_col_XYZ2sRGB( int range, int *lut,
int Yi;
float v;
/* XYZ can be Nan, Inf etc. Throw those values out, they will break
* our clipping.
*/
if( !isnormal( X ) ||
!isnormal( Y ) ||
!isnormal( Z ) ) {
*r = 0;
*g = 0;
*b = 0;
return( -1 );
}
/* Multiply through the matrix to get luminosity values.
*/
Yr = vips_mat_XYZ2RGB[0][0] * X +