1 diff --git a/third_party/libtiff/tif_dir.c b/third_party/libtiff/tif_dir.c 2 index 73212c02d..16ce3d3ce 100644 3 --- a/third_party/libtiff/tif_dir.c 4 +++ b/third_party/libtiff/tif_dir.c 5 @@ -426,6 +426,14 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap) 6 case TIFFTAG_REFERENCEBLACKWHITE: 7 /* XXX should check for null range */ 8 _TIFFsetFloatArray(&td->td_refblackwhite, va_arg(ap, float*), 6); 9 + for (int i = 0; i < 6; i++) { 10 + if (isnan(td->td_refblackwhite[i])) { 11 + if (i % 2 == 0) 12 + td->td_refblackwhite[i] = 0; 13 + else 14 + td->td_refblackwhite[i] = pow(2, td->td_bitspersample) - 1; 15 + } 16 + } 17 break; 18 case TIFFTAG_INKNAMES: 19 v = (uint16) va_arg(ap, uint16_vap); 20