From da87178a25291c00081c9cc205eaa6a6e3883844 Mon Sep 17 00:00:00 2001 From: aramis_acg Date: Tue, 13 Apr 2010 15:51:18 +0000 Subject: [PATCH] Fix: OgreImporter overflows a vector if no weight assignments are given. git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@676 67173fc5-114c-0410-ac8e-9d2fd5bffc1f --- code/OgreImporter.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/code/OgreImporter.cpp b/code/OgreImporter.cpp index f0a8c21e1..66883ae01 100644 --- a/code/OgreImporter.cpp +++ b/code/OgreImporter.cpp @@ -260,7 +260,7 @@ void OgreImporter::ReadSubMesh(SubMesh &theSubMesh, XmlReader *Reader) vector UniquePositions(UniqueVertexCount); vector UniqueNormals(UniqueVertexCount); vector UniqueUvs(UniqueVertexCount); - vector< vector > UniqueWeights(UniqueVertexCount); + vector< vector > UniqueWeights((theSubMesh.Weights.size() ? UniqueVertexCount : 0)); for(unsigned int i=0; imNumBones=aiBones.size(); - NewAiMesh->mBones=new aiBone* [aiBones.size()]; - memcpy(NewAiMesh->mBones, &(aiBones[0]), aiBones.size()*sizeof(aiBone*)); + + // mBones must be NULL if mNumBones is non 0 or the validation fails. + if (aiBones.size()) { + NewAiMesh->mBones=new aiBone* [aiBones.size()]; + memcpy(NewAiMesh->mBones, &(aiBones[0]), aiBones.size()*sizeof(aiBone*)); + } //______________________________________________________________________________________________________