# STLLoader: avoid potential division by zero.
# irrMeshLoader: fix potentially uninitialized variable. Thanks to erikbuck for pointing these out (http://sourceforge.net/projects/assimp/forums/forum/817653/topic/4691387). git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@1076 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
This commit is contained in:
@@ -186,7 +186,7 @@ void STLImporter::LoadASCIIFile()
|
||||
|
||||
// try to guess how many vertices we could have
|
||||
// assume we'll need 160 bytes for each face
|
||||
pMesh->mNumVertices = ( pMesh->mNumFaces = fileSize / 160 ) * 3;
|
||||
pMesh->mNumVertices = ( pMesh->mNumFaces = std::max(1u,fileSize / 160u )) * 3;
|
||||
pMesh->mVertices = new aiVector3D[pMesh->mNumVertices];
|
||||
pMesh->mNormals = new aiVector3D[pMesh->mNumVertices];
|
||||
|
||||
@@ -207,6 +207,8 @@ void STLImporter::LoadASCIIFile()
|
||||
DefaultLogger::get()->warn("STL: A new facet begins but the old is not yet complete");
|
||||
}
|
||||
if (pMesh->mNumFaces == curFace) {
|
||||
ai_assert(pMesh->mNumFaces != 0);
|
||||
|
||||
// need to resize the arrays, our size estimate was wrong
|
||||
unsigned int iNeededSize = (unsigned int)(sz-mBuffer) / pMesh->mNumFaces;
|
||||
if (iNeededSize <= 160)iNeededSize >>= 1; // prevent endless looping
|
||||
|
||||
Reference in New Issue
Block a user