DevIL icon indicating copy to clipboard operation
DevIL copied to clipboard

ilCopyPixels crashes loading RGBA-paletted bmps as luminance images

Open TheHugeManatee opened this issue 8 years ago • 1 comments

ilCopyPixels() will crash when copying a bmp image with an RGBA/BGRA-palette as IL_LUMINANCE

Debugging shows this is a problem of iConvertPalette(), where a palette with bpp=4 is not treated correctly, causing an integer to underflow.

sample image is attached. test.zip

TheHugeManatee avatar Feb 07 '17 16:02 TheHugeManatee

See https://github.com/TheHugeManatee/DevIL/commit/a951650e59ca575d6f5bdca9fc84e47ce0b66e8c for a possible fix. This would do fine for now, preventing j to underflow for Size >= 4 but will not be robust for color palettes with bpp other than 3 or 4. Currently, ilGetBppPal() only returns 0, 3 or 4, where 0 still will result in an indefinite loop..

TheHugeManatee avatar Feb 07 '17 17:02 TheHugeManatee