Parcourir la source

Replace assertion by an exception in Obj parsing

This crash could happen when the user try to parse an ill-formed obj file.
Alexandre Avenel il y a 7 ans
Parent
commit
606fd6b1a1
1 fichiers modifiés avec 2 ajouts et 1 suppressions
  1. 2 1
      code/ObjFileParser.cpp

+ 2 - 1
code/ObjFileParser.cpp

@@ -353,7 +353,8 @@ void ObjFileParser::getHomogeneousVector3( std::vector<aiVector3D> &point3d_arra
     copyNextWord( m_buffer, Buffersize );
     w = ( ai_real ) fast_atof( m_buffer );
 
-    ai_assert( w != 0 );
+    if (w == 0)
+      throw DeadlyImportError("OBJ: Invalid component in homogeneous vector (Division by zero)");
 
     point3d_array.push_back( aiVector3D( x/w, y/w, z/w ) );
     m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );