2014.12.27 23:06 "[Tiff] [PATCH] tiff2ps: fix grayscale with unassociated alpha (and other extrasamples != 0)", by Yuriy M. Kaminskiy

2014.12.31 09:36 "Re: [Tiff] [PATCH] tif_luv, tif_pixarlog, ppm2tiff: get rid of duplicates of TIFFSafeMultiply", by Jürgen_Buchmüller

Am Mittwoch, den 31.12.2014, 00:45 +0300 schrieb Yuriy M. Kaminskiy: > It's in CVS HEAD, commit that added it:

I see it now. It won't work right for negative numbers m1 and m2, and then tmsize_t may be either 32 or 64 bit signed, depending on the target environment being 32- or 64-bit. An adequate check could look like this

 static tmsize_t
 add_ms(tmsize_t m1, tmsize_t m2)
 {

        tmsize_t bytes = m1 + m2;

        if (m1 > 0 && m2 > 0 && (uint64)bytes != (uint64)m1 +
(uint64)m2)
                bytes = 0;
        if (m1 < 0 && m2 < 0 && (uint64)-bytes != (uint64)-m1 +
(uint64)-m2)
                bytes = 0;

return bytes;

}

I think using uint64 casts for the comparisons is sufficient, because tmsize_t is either int32 or int64. The negative numbers path will not be taken at all in reality, it's just there for completeness sake.

Jürgen