diff options
author | Liang Qi <liang.qi@qt.io> | 2016-05-26 09:40:39 +0200 |
---|---|---|
committer | Paul Olav Tvete <paul.tvete@theqtcompany.com> | 2016-05-26 13:04:32 +0200 |
commit | 2fb026d58b45f50ed7d5666de58c9184e81bbc60 (patch) | |
tree | ad1a80d7e2579899c55fce7771472a7d9176af0e /src/gui/image/qbmphandler.cpp | |
parent | 184b2ea4ea9c3e4ad735ff67c5a399e9613da8ab (diff) | |
parent | 540978288ea0f6ed0b166bb9207f427a4c825ab6 (diff) |
Merge remote-tracking branch 'origin/5.6.1' into 5.7.0
Conflicts:
src/corelib/tools/qsimd_p.h
src/network/socket/qnativesocketengine_winrt.cpp
Change-Id: I2765b671664c2a84839b2f88ba724fdf0c1fa7c6
Diffstat (limited to 'src/gui/image/qbmphandler.cpp')
-rw-r--r-- | src/gui/image/qbmphandler.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/gui/image/qbmphandler.cpp b/src/gui/image/qbmphandler.cpp index b8290861af..9545abfd21 100644 --- a/src/gui/image/qbmphandler.cpp +++ b/src/gui/image/qbmphandler.cpp @@ -289,6 +289,12 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, int offset, int format = QImage::Format_Mono; } + if (depth != 32) { + ncols = bi.biClrUsed ? bi.biClrUsed : 1 << nbits; + if (ncols < 1 || ncols > 256) // sanity check - don't run out of mem if color table is broken + return false; + } + if (bi.biHeight < 0) h = -h; // support images with negative height @@ -296,19 +302,15 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, int offset, int image = QImage(w, h, format); if (image.isNull()) // could not create image return false; - } - - if (depth != 32) { - ncols = bi.biClrUsed ? bi.biClrUsed : 1 << nbits; - if (ncols < 1 || ncols > 256) // sanity check - don't run out of mem if color table is broken - return false; - image.setColorCount(ncols); + if (ncols) + image.setColorCount(ncols); // Ensure valid QImage } image.setDotsPerMeterX(bi.biXPelsPerMeter); image.setDotsPerMeterY(bi.biYPelsPerMeter); if (ncols > 0) { // read color table + image.setColorCount(ncols); uchar rgb[4]; int rgb_len = t == BMP_OLD ? 3 : 4; for (int i=0; i<ncols; i++) { |