瀏覽代碼

Merge pull request #5129 from sashashura/4875566380220416

Fix UNKNOWN READ in aiTexture::~aiTexture
Kim Kulling 2 年之前
父節點
當前提交
02d5ab294c
共有 2 個文件被更改,包括 9 次插入2 次删除
  1. 1 1
      code/AssetLib/MDL/MDLLoader.cpp
  2. 8 1
      code/AssetLib/MDL/MDLMaterialLoader.cpp

+ 1 - 1
code/AssetLib/MDL/MDLLoader.cpp

@@ -274,7 +274,7 @@ void MDLImporter::InternReadFile(const std::string &pFile,
 // ------------------------------------------------------------------------------------------------
 // Check whether we're still inside the valid file range
 void MDLImporter::SizeCheck(const void *szPos) {
-    if (!szPos || (const unsigned char *)szPos > this->mBuffer + this->iFileSize) {
+    if (!szPos || (const unsigned char *)szPos > this->mBuffer + this->iFileSize || szPos < this->mBuffer) {
         throw DeadlyImportError("Invalid MDL file. The file is too small "
                                 "or contains invalid data.");
     }

+ 8 - 1
code/AssetLib/MDL/MDLMaterialLoader.cpp

@@ -703,7 +703,14 @@ void MDLImporter::SkipSkinLump_3DGS_MDL7(
             tex.pcData = bad_texel;
             tex.mHeight = iHeight;
             tex.mWidth = iWidth;
-            ParseTextureColorData(szCurrent, iMasked, &iSkip, &tex);
+
+            try {
+                ParseTextureColorData(szCurrent, iMasked, &iSkip, &tex);
+            } catch (...) {
+                // FIX: Important, otherwise the destructor will crash
+                tex.pcData = nullptr;
+                throw;
+            }
 
             // FIX: Important, otherwise the destructor will crash
             tex.pcData = nullptr;