diff --git a/src/plugins/imageformats/tga/qtgafile.cpp b/src/plugins/imageformats/tga/qtgafile.cpp index 97510dfb4c074809fce86483fb23592d223bfcdb..5d086c67356aa76bbdae64ebfb53ab218c3ca7c8 100644 --- a/src/plugins/imageformats/tga/qtgafile.cpp +++ b/src/plugins/imageformats/tga/qtgafile.cpp @@ -163,6 +163,12 @@ QTgaFile::QTgaFile(QIODevice *device) if (!validDepth) { mErrorMessage = tr("Image depth not valid"); + return; + } + if (quint64(width()) * quint64(height()) > (8192 * 8192)) + { + mErrorMessage = tr("Image size exceeds limit"); + return; } int curPos = mDevice->pos(); int fileBytes = mDevice->size(); @@ -233,6 +239,8 @@ QImage QTgaFile::readImage() unsigned char yCorner = desc & 0x20; // 0 = lower, 1 = upper QImage im(imageWidth, imageHeight, QImage::Format_ARGB32); + if (im.isNull()) + return QImage(); TgaReader *reader = 0; if (bitsPerPixel == 16) reader = new Tga16Reader();