* Source/NSBitmapImageRep.m (-_convertToFormatBitsPerSample:...):

+	Correct division by zero bug in image conversion.
This commit is contained in:
fredkiefer 2019-12-02 22:46:44 +01:00
parent ecb1cb0f48
commit 7f07e4dd43
2 changed files with 9 additions and 2 deletions

View file

@ -2429,7 +2429,8 @@ _set_bit_value(unsigned char *base, long msb_off, int bit_width,
}
fa = ia / _scale;
if ((_format & NSAlphaNonpremultipliedBitmapFormat) !=
if ((ia != 0 && fa < 1.0) &&
(_format & NSAlphaNonpremultipliedBitmapFormat) !=
(bitmapFormat & NSAlphaNonpremultipliedBitmapFormat))
{
if (_format & NSAlphaNonpremultipliedBitmapFormat)
@ -2568,7 +2569,8 @@ _set_bit_value(unsigned char *base, long msb_off, int bit_width,
fv = iv / _scale;
fa = ia / _scale;
if ((_format & NSAlphaNonpremultipliedBitmapFormat) !=
if ((ia != 0 && fa < 1.0) &&
(_format & NSAlphaNonpremultipliedBitmapFormat) !=
(bitmapFormat & NSAlphaNonpremultipliedBitmapFormat))
{
if (_format & NSAlphaNonpremultipliedBitmapFormat)