glTF importer - clean all member arrays

When importing more than one scene using the same gtlf importer loading fails with error 'bad array new length'. This happens because 'meshOffsets' are not cleared and the importer continues to push_back values at the end. Adjacent values are then used to calculate the length of 'mMeshes' array. This calculation expects that each value is higher than the previous otherwise we get negative length. But when pushin at the end of uncleared array we get contents like this: 0,1,2,3,0,1,2. Then when calculating 0-3 we try to allocate array of length -3 and get this exception.
pull/2501/head
petrmohelnik 2019-06-05 18:51:49 +02:00
parent 83237de02f
commit 1855bf44f9
2 changed files with 10 additions and 2 deletions

View File

@ -1130,7 +1130,11 @@ void glTF2Importer::ImportEmbeddedTextures(glTF2::Asset& r)
}
}
void glTF2Importer::InternReadFile(const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler) {
void glTF2Importer::InternReadFile(const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler)
{
// clean all member arrays
meshOffsets.clear();
embeddedTexIdxs.clear();
this->mScene = pScene;

View File

@ -717,7 +717,11 @@ void glTFImporter::ImportEmbeddedTextures(glTF::Asset& r)
}
}
void glTFImporter::InternReadFile(const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler) {
void glTFImporter::InternReadFile(const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler)
{
// clean all member arrays
meshOffsets.clear();
embeddedTexIdxs.clear();
this->mScene = pScene;