Explorar o código

Merge branch 'master' into dependabot/github_actions/actions/cache-3

Kim Kulling %!s(int64=3) %!d(string=hai) anos
pai
achega
744ed2256b
Modificáronse 2 ficheiros con 13 adicións e 3 borrados
  1. 1 1
      .github/workflows/ccpp.yml
  2. 12 2
      code/AssetLib/Q3D/Q3DLoader.cpp

+ 1 - 1
.github/workflows/ccpp.yml

@@ -71,7 +71,7 @@ jobs:
 
 
     - name: Remove contrib directory for Hunter builds
     - name: Remove contrib directory for Hunter builds
       if: contains(matrix.name, 'hunter')
       if: contains(matrix.name, 'hunter')
-      uses: JesseTG/[email protected].2
+      uses: JesseTG/[email protected].3
       with:
       with:
         path: contrib
         path: contrib
 
 

+ 12 - 2
code/AssetLib/Q3D/Q3DLoader.cpp

@@ -129,10 +129,20 @@ void Q3DImporter::InternReadFile(const std::string &pFile,
     unsigned int numTextures = (unsigned int)stream.GetI4();
     unsigned int numTextures = (unsigned int)stream.GetI4();
 
 
     std::vector<Material> materials;
     std::vector<Material> materials;
-    materials.reserve(numMats);
+    try {
+        materials.reserve(numMats);
+    } catch(const std::bad_alloc&) {
+        ASSIMP_LOG_ERROR("Invalid alloc for materials.");
+        throw DeadlyImportError("Invalid Quick3D-file, material allocation failed.");
+    }
 
 
     std::vector<Mesh> meshes;
     std::vector<Mesh> meshes;
-    meshes.reserve(numMeshes);
+    try {
+        meshes.reserve(numMeshes);
+    } catch(const std::bad_alloc&) {
+        ASSIMP_LOG_ERROR("Invalid alloc for meshes.");
+        throw DeadlyImportError("Invalid Quick3D-file, mesh allocation failed.");
+    }
 
 
     // Allocate the scene root node
     // Allocate the scene root node
     pScene->mRootNode = new aiNode();
     pScene->mRootNode = new aiNode();