Browse Source

Merge pull request #813 from tgoulart/obj_loader_leak

Fix memory leak in OBJ loader when a mesh has no faces.
Kim Kulling 9 years ago
parent
commit
80f4e69938
1 changed files with 5 additions and 1 deletions
  1. 5 1
      code/ObjFileImporter.cpp

+ 5 - 1
code/ObjFileImporter.cpp

@@ -308,7 +308,11 @@ aiMesh *ObjFileImporter::createTopology( const ObjFile::Model* pModel, const Obj
     if( !pObjMesh ) {
     if( !pObjMesh ) {
         return NULL;
         return NULL;
     }
     }
-    ai_assert( NULL != pObjMesh );
+
+    if( pObjMesh->m_Faces.empty() ) {
+        return NULL;
+    }
+
     aiMesh* pMesh = new aiMesh;
     aiMesh* pMesh = new aiMesh;
     if( !pObjMesh->m_name.empty() ) {
     if( !pObjMesh->m_name.empty() ) {
         pMesh->mName.Set( pObjMesh->m_name );
         pMesh->mName.Set( pObjMesh->m_name );