mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 10:22:48 +00:00
kimgio: handle dummy BMP image size in ico plugin
fixes loading of some images such as the favicon of https://www.sftp.net/ Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
90928e8320
commit
bb8c1bfb2d
1 changed files with 14 additions and 11 deletions
|
@ -194,17 +194,6 @@ bool ICOHandler::read(QImage *image)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (Q_UNLIKELY(bmpimagesize >= INT_MAX)) {
|
||||
kWarning() << "BMP image size is too big" << bmpimagesize;
|
||||
return false;
|
||||
}
|
||||
|
||||
imagebytes.resize(bmpimagesize);
|
||||
if (Q_UNLIKELY(datastream.readRawData(imagebytes.data(), bmpimagesize) != bmpimagesize)) {
|
||||
kWarning() << "Could not read BMP image data";
|
||||
return false;
|
||||
}
|
||||
|
||||
// fallbacks
|
||||
const int imagewidth = (icowidth ? icowidth : bmpwidth);
|
||||
const int imageheight = (icoheight ? icoheight : bmpheight);
|
||||
|
@ -227,6 +216,20 @@ bool ICOHandler::read(QImage *image)
|
|||
}
|
||||
}
|
||||
|
||||
if (Q_UNLIKELY(bmpimagesize == 0)) {
|
||||
kDebug() << "BMP image size is dummy" << bmpimagesize << imageboundary;
|
||||
bmpimagesize = imageboundary;
|
||||
} else if (Q_UNLIKELY(bmpimagesize >= INT_MAX)) {
|
||||
kWarning() << "BMP image size is too big" << bmpimagesize;
|
||||
return false;
|
||||
}
|
||||
|
||||
imagebytes.resize(bmpimagesize);
|
||||
if (Q_UNLIKELY(datastream.readRawData(imagebytes.data(), bmpimagesize) != bmpimagesize)) {
|
||||
kWarning() << "Could not read BMP image data";
|
||||
return false;
|
||||
}
|
||||
|
||||
QImage bmpimage(imagewidth, imageheight, imageformat);
|
||||
if (Q_UNLIKELY(bmpimage.isNull())) {
|
||||
kWarning() << "Could not create BMP image" << imagewidth << imageheight << imageformat;
|
||||
|
|
Loading…
Add table
Reference in a new issue