xbm image format: avoid uninitialized pixels for truncated data

xbm bitmaps are conventionally accepted as valid even if there is not
enough data to fill the declared bitmap size: both ImageMagick and
GIMP do this. Qt did too, but the uncovered areas would be
uninitialized, and thus contain random junk bits. This commit adds
clearing of the full QImage data.

Task-number: QTBUG-54169
Change-Id: I84150d54d07dbd546a4947e7ec332f83f2d7ca41
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
This commit is contained in:
Eirik Aavitsland 2017-02-27 14:41:19 +01:00
parent 05a71c6c7f
commit 901ed36f36

View File

@ -143,6 +143,8 @@ static bool read_xbm_body(QIODevice *device, int w, int h, QImage *outImage)
return false; return false;
} }
outImage->fill(Qt::color0); // in case the image data does not cover the full image
outImage->setColorCount(2); outImage->setColorCount(2);
outImage->setColor(0, qRgb(255,255,255)); // white outImage->setColor(0, qRgb(255,255,255)); // white
outImage->setColor(1, qRgb(0,0,0)); // black outImage->setColor(1, qRgb(0,0,0)); // black