bmp image handler: Reject invalid 0-dimension files early

Avoid spending time on decoding attempt of invalid bmp files
specifying height or width as 0.

Change-Id: Ia6666088515eee54777f7154868fb7d07c6b4438
Done-with: Albert Astals Cid <albert.astals.cid@kdab.com>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Albert Astals Cid <albert.astals.cid@kdab.com>
bb10
Eirik Aavitsland 2019-01-04 10:32:28 +01:00 committed by Jani Heikkinen
parent 81c3c66bb4
commit 74c8aa7608
1 changed files with 1 additions and 1 deletions

View File

@ -188,7 +188,7 @@ static bool read_dib_infoheader(QDataStream &s, BMP_INFOHDR &bi)
if (!(comp == BMP_RGB || (nbits == 4 && comp == BMP_RLE4) ||
(nbits == 8 && comp == BMP_RLE8) || ((nbits == 16 || nbits == 32) && comp == BMP_BITFIELDS)))
return false; // weird compression type
if (bi.biWidth < 0 || quint64(bi.biWidth) * qAbs(bi.biHeight) > 16384 * 16384)
if (bi.biWidth <= 0 || !bi.biHeight || quint64(bi.biWidth) * qAbs(bi.biHeight) > 16384 * 16384)
return false;
return true;