Skip to content

armgit / krita

Public Imported from GitHub
0

Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.

C++

Fix a crash in KisTgaImport

Dmitry Kazakov90f1de137d54
diff --git a/plugins/impex/tga/kis_tga_import.cpp b/plugins/impex/tga/kis_tga_import.cpp
index ec0ca3911f..98fbf01ac5 100644
--- a/plugins/impex/tga/kis_tga_import.cpp
+++ b/plugins/impex/tga/kis_tga_import.cpp
@@ -152,6 +152,11 @@ static bool loadTGA(QDataStream & s, const TgaHeader & tga, QImage &img)
uint count = (c & 0x7f) + 1;
num -= count * pixel_size;
+ if (num < 0) {
+ dbgFile << "This TGA file is broken: the number of pixels left to read and the number of RLE pixels do not agree" << ppVar(num) << ppVar(count) << ppVar(pixel_size);
+ return false;
+ }
+
if (c & 0x80) {
// RLE pixels.
Q_ASSERT(pixel_size <= 8);