Blob Blame History Raw
diff --git a/src/plugins/imageformats/tga/qtgafile.cpp b/src/plugins/imageformats/tga/qtgafile.cpp
index 205e60b6..0f84864e 100644
--- a/src/plugins/imageformats/tga/qtgafile.cpp
+++ b/src/plugins/imageformats/tga/qtgafile.cpp
@@ -166,6 +166,11 @@ QTgaFile::QTgaFile(QIODevice *device)
     {
         mErrorMessage = QObject::tr("Image depth not valid");
     }
+    if (quint64(width()) * quint64(height()) > (8192 * 8192))
+    {
+        mErrorMessage = QObject::tr("Image size exceeds limit");
+        return;
+    }
     int fileBytes = mDevice->size();
     if (!mDevice->seek(fileBytes - FooterSize))
     {
@@ -237,6 +242,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();