122238 Use after free
parent
3f53ffa576
commit
4872c4caf8
|
@ -806,4 +806,4 @@ void DNA::RegisterConverters() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif ASSIMP_BUILD_NO_BLEND_IMPORTER
|
#endif //ASSIMP_BUILD_NO_BLEND_IMPORTER
|
||||||
|
|
|
@ -116,14 +116,18 @@ const aiImporterDesc* IRRMeshImporter::GetInfo () const
|
||||||
return &desc;
|
return &desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void releaseMaterial( aiMaterial *mat ) {
|
static void releaseMaterial( aiMaterial **mat ) {
|
||||||
delete mat;
|
if(*mat!= nullptr) {
|
||||||
mat = nullptr;
|
delete *mat;
|
||||||
|
*mat = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void releaseMesh( aiMesh *mesh ) {
|
static void releaseMesh( aiMesh **mesh ) {
|
||||||
delete mesh;
|
if (*mesh != nullptr){
|
||||||
mesh = nullptr;
|
delete *mesh;
|
||||||
|
*mesh = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
@ -148,8 +152,8 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
|
||||||
meshes.reserve(5);
|
meshes.reserve(5);
|
||||||
|
|
||||||
// temporary data - current mesh buffer
|
// temporary data - current mesh buffer
|
||||||
aiMaterial* curMat = NULL;
|
aiMaterial* curMat = nullptr;
|
||||||
aiMesh* curMesh = NULL;
|
aiMesh* curMesh = nullptr;
|
||||||
unsigned int curMatFlags = 0;
|
unsigned int curMatFlags = 0;
|
||||||
|
|
||||||
std::vector<aiVector3D> curVertices,curNormals,curTangents,curBitangents;
|
std::vector<aiVector3D> curVertices,curNormals,curTangents,curBitangents;
|
||||||
|
@ -170,14 +174,14 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
|
||||||
// end of previous buffer. A material and a mesh should be there
|
// end of previous buffer. A material and a mesh should be there
|
||||||
if ( !curMat || !curMesh) {
|
if ( !curMat || !curMesh) {
|
||||||
DefaultLogger::get()->error("IRRMESH: A buffer must contain a mesh and a material");
|
DefaultLogger::get()->error("IRRMESH: A buffer must contain a mesh and a material");
|
||||||
releaseMaterial( curMat );
|
releaseMaterial( &curMat );
|
||||||
releaseMesh( curMesh );
|
releaseMesh( &curMesh );
|
||||||
} else {
|
} else {
|
||||||
materials.push_back(curMat);
|
materials.push_back(curMat);
|
||||||
meshes.push_back(curMesh);
|
meshes.push_back(curMesh);
|
||||||
}
|
}
|
||||||
curMat = NULL;
|
curMat = nullptr;
|
||||||
curMesh = NULL;
|
curMesh = nullptr;
|
||||||
|
|
||||||
curVertices.clear();
|
curVertices.clear();
|
||||||
curColors.clear();
|
curColors.clear();
|
||||||
|
@ -192,7 +196,7 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
|
||||||
if (!ASSIMP_stricmp(reader->getNodeName(),"material")) {
|
if (!ASSIMP_stricmp(reader->getNodeName(),"material")) {
|
||||||
if (curMat) {
|
if (curMat) {
|
||||||
DefaultLogger::get()->warn("IRRMESH: Only one material description per buffer, please");
|
DefaultLogger::get()->warn("IRRMESH: Only one material description per buffer, please");
|
||||||
releaseMaterial( curMat );
|
releaseMaterial( &curMat );
|
||||||
}
|
}
|
||||||
curMat = ParseMaterial(curMatFlags);
|
curMat = ParseMaterial(curMatFlags);
|
||||||
}
|
}
|
||||||
|
@ -204,8 +208,8 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
|
||||||
// This is possible ... remove the mesh from the list and skip further reading
|
// This is possible ... remove the mesh from the list and skip further reading
|
||||||
DefaultLogger::get()->warn("IRRMESH: Found mesh with zero vertices");
|
DefaultLogger::get()->warn("IRRMESH: Found mesh with zero vertices");
|
||||||
|
|
||||||
releaseMaterial( curMat );
|
releaseMaterial( &curMat );
|
||||||
releaseMesh( curMesh );
|
releaseMesh( &curMesh );
|
||||||
textMeaning = 0;
|
textMeaning = 0;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -248,7 +252,7 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
|
||||||
vertexFormat = 2;
|
vertexFormat = 2;
|
||||||
}
|
}
|
||||||
else if (ASSIMP_stricmp("standard", t)) {
|
else if (ASSIMP_stricmp("standard", t)) {
|
||||||
releaseMaterial( curMat );
|
releaseMaterial( &curMat );
|
||||||
DefaultLogger::get()->warn("IRRMESH: Unknown vertex format");
|
DefaultLogger::get()->warn("IRRMESH: Unknown vertex format");
|
||||||
}
|
}
|
||||||
else vertexFormat = 0;
|
else vertexFormat = 0;
|
||||||
|
@ -256,7 +260,7 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
|
||||||
}
|
}
|
||||||
else if (!ASSIMP_stricmp(reader->getNodeName(),"indices")) {
|
else if (!ASSIMP_stricmp(reader->getNodeName(),"indices")) {
|
||||||
if (curVertices.empty() && curMat) {
|
if (curVertices.empty() && curMat) {
|
||||||
releaseMaterial( curMat );
|
releaseMaterial( &curMat );
|
||||||
throw DeadlyImportError("IRRMESH: indices must come after vertices");
|
throw DeadlyImportError("IRRMESH: indices must come after vertices");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -272,10 +276,10 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
|
||||||
DefaultLogger::get()->warn("IRRMESH: Found mesh with zero indices");
|
DefaultLogger::get()->warn("IRRMESH: Found mesh with zero indices");
|
||||||
|
|
||||||
// mesh - away
|
// mesh - away
|
||||||
releaseMesh( curMesh );
|
releaseMesh( &curMesh );
|
||||||
|
|
||||||
// material - away
|
// material - away
|
||||||
releaseMaterial( curMat );
|
releaseMaterial( &curMat );
|
||||||
|
|
||||||
textMeaning = 0;
|
textMeaning = 0;
|
||||||
continue;
|
continue;
|
||||||
|
@ -487,8 +491,8 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
|
||||||
if (curMat || curMesh) {
|
if (curMat || curMesh) {
|
||||||
if ( !curMat || !curMesh) {
|
if ( !curMat || !curMesh) {
|
||||||
DefaultLogger::get()->error("IRRMESH: A buffer must contain a mesh and a material");
|
DefaultLogger::get()->error("IRRMESH: A buffer must contain a mesh and a material");
|
||||||
releaseMaterial( curMat );
|
releaseMaterial( &curMat );
|
||||||
releaseMesh( curMesh );
|
releaseMesh( &curMesh );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
materials.push_back(curMat);
|
materials.push_back(curMat);
|
||||||
|
|
Loading…
Reference in New Issue