bmp/ico decoder: fail early for unsupported bit depths

All the normal bit depths are supported, so no point in trying to go
through the decoding code path for others. Avoids wide bitshift
warning for claimed depths > 32.

Change-Id: I61b72dbbf9558ca28db46f8168339f8174e56997
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
(cherry picked from commit 6a2224fd58414a78957104dd654f697c4b2eaa1d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Eirik Aavitsland 2020-05-29 15:15:01 +02:00 committed by Qt Cherry-pick Bot
parent 26dc7f012a
commit 33c98d8fff
2 changed files with 10 additions and 2 deletions

View File

@ -262,9 +262,13 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
depth = 8;
format = QImage::Format_Indexed8;
break;
default:
case 1:
depth = 1;
format = QImage::Format_Mono;
break;
default:
return false;
break;
}
if (depth != 32) {

View File

@ -491,8 +491,12 @@ QImage ICOReader::iconAt(int index)
case 4:
icoAttrib.depth = 8;
break;
default:
case 1:
icoAttrib.depth = 1;
break;
default:
return img;
break;
}
if (icoAttrib.depth == 32) // there's no colormap
icoAttrib.ncolors = 0;