Check for QImage allocation failure in qgifhandler

Since image files easily can be (or corrupt files claim to be) huge,
it is worth checking for out of memory situations.

Change-Id: I635a3ec6852288079fdec4e14cf7e776fe59e9e0
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
bb10
Eirik Aavitsland 2018-08-03 13:25:15 +02:00
parent 64a560d977
commit 2841e2b61e
1 changed files with 6 additions and 1 deletions

View File

@ -354,7 +354,8 @@ int QGIFFormat::decode(QImage *image, const uchar *buffer, int length,
(*image) = QImage(swidth, sheight, format);
bpl = image->bytesPerLine();
bits = image->bits();
memset(bits, 0, image->sizeInBytes());
if (bits)
memset(bits, 0, image->sizeInBytes());
}
// Check if the previous attempt to create the image failed. If it
@ -415,6 +416,10 @@ int QGIFFormat::decode(QImage *image, const uchar *buffer, int length,
backingstore = QImage(qMax(backingstore.width(), w),
qMax(backingstore.height(), h),
QImage::Format_RGB32);
if (backingstore.isNull()) {
state = Error;
return -1;
}
memset(backingstore.bits(), 0, backingstore.sizeInBytes());
}
const int dest_bpl = backingstore.bytesPerLine();