Browse Source

MDLLoader: Replace raw pointer with vector to fix a memory leak

Turo Lamminen 7 năm trước cách đây
mục cha
commit
9344074a04
2 tập tin đã thay đổi với 3 bổ sung3 xóa
  1. 2 2
      code/MDLFileData.h
  2. 1 1
      code/MDLLoader.cpp

+ 2 - 2
code/MDLFileData.h

@@ -844,11 +844,11 @@ struct IntGroupInfo_MDL7
 struct IntGroupData_MDL7
 {
     IntGroupData_MDL7()
-        : pcFaces(NULL), bNeed2UV(false)
+        : bNeed2UV(false)
     {}
 
     //! Array of faces that belong to the group
-    MDL::IntFace_MDL7* pcFaces;
+    std::vector<MDL::IntFace_MDL7> pcFaces;
 
     //! Array of vertex positions
     std::vector<aiVector3D>     vPositions;

+ 1 - 1
code/MDLLoader.cpp

@@ -1502,7 +1502,7 @@ void MDLImporter::InternReadFile_3DGS_MDL7( )
                     groupData.bNeed2UV = true;
                 }
             }
-            groupData.pcFaces = new MDL::IntFace_MDL7[groupInfo.pcGroup->numtris];
+            groupData.pcFaces.resize(groupInfo.pcGroup->numtris);
 
             // read all faces into the preallocated arrays
             ReadFaces_3DGS_MDL7(groupInfo, groupData);