From 901ed36f3649fc77e5dc4078c0f0e485732feb7a Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Mon, 27 Feb 2017 14:41:19 +0100 Subject: 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 --- src/gui/image/qxbmhandler.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/gui/image/qxbmhandler.cpp b/src/gui/image/qxbmhandler.cpp index 19015c5dcd..155a4f88b4 100644 --- a/src/gui/image/qxbmhandler.cpp +++ b/src/gui/image/qxbmhandler.cpp @@ -143,6 +143,8 @@ static bool read_xbm_body(QIODevice *device, int w, int h, QImage *outImage) return false; } + outImage->fill(Qt::color0); // in case the image data does not cover the full image + outImage->setColorCount(2); outImage->setColor(0, qRgb(255,255,255)); // white outImage->setColor(1, qRgb(0,0,0)); // black -- cgit v1.2.3