diff --git a/code/IRRMeshLoader.cpp b/code/IRRMeshLoader.cpp index 12ad80779..97984e842 100644 --- a/code/IRRMeshLoader.cpp +++ b/code/IRRMeshLoader.cpp @@ -118,7 +118,7 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile, // temporary data - current mesh buffer aiMaterial* curMat = NULL; aiMesh* curMesh = NULL; - unsigned int curMatFlags; + unsigned int curMatFlags = 0; std::vector curVertices,curNormals,curTangents,curBitangents; std::vector curColors; diff --git a/code/STLLoader.cpp b/code/STLLoader.cpp index 9a84dd753..07227305e 100644 --- a/code/STLLoader.cpp +++ b/code/STLLoader.cpp @@ -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