Blame SOURCES/qt-tga-handler-check-for-out-of-range-image-size.patch

80a0e2
diff --git a/src/plugins/imageformats/tga/qtgafile.cpp b/src/plugins/imageformats/tga/qtgafile.cpp
80a0e2
index 205e60b6..0f84864e 100644
80a0e2
--- a/src/plugins/imageformats/tga/qtgafile.cpp
80a0e2
+++ b/src/plugins/imageformats/tga/qtgafile.cpp
80a0e2
@@ -166,6 +166,11 @@ QTgaFile::QTgaFile(QIODevice *device)
80a0e2
     {
80a0e2
         mErrorMessage = QObject::tr("Image depth not valid");
80a0e2
     }
80a0e2
+    if (quint64(width()) * quint64(height()) > (8192 * 8192))
80a0e2
+    {
80a0e2
+        mErrorMessage = QObject::tr("Image size exceeds limit");
80a0e2
+        return;
80a0e2
+    }
80a0e2
     int fileBytes = mDevice->size();
80a0e2
     if (!mDevice->seek(fileBytes - FooterSize))
80a0e2
     {
80a0e2
@@ -237,6 +242,8 @@ QImage QTgaFile::readImage()
80a0e2
     unsigned char yCorner = desc & 0x20; // 0 = lower, 1 = upper
80a0e2
 
80a0e2
     QImage im(imageWidth, imageHeight, QImage::Format_ARGB32);
80a0e2
+    if (im.isNull())
80a0e2
+        return QImage();
80a0e2
     TgaReader *reader = 0;
80a0e2
     if (bitsPerPixel == 16)
80a0e2
         reader = new Tga16Reader();