Fix issue #1623 : crash when loading multiple PLY files
Pointer mGeneratedMesh was not reset to nullptr when transfering ownership to pScene->mMeshespull/1636/head
parent
89ff8fc05d
commit
50bcaf39fd
|
@ -91,9 +91,9 @@ namespace
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Constructor to be privately used by Importer
|
// Constructor to be privately used by Importer
|
||||||
PLYImporter::PLYImporter()
|
PLYImporter::PLYImporter()
|
||||||
: mBuffer()
|
: mBuffer(nullptr)
|
||||||
, pcDOM()
|
, pcDOM(nullptr)
|
||||||
, mGeneratedMesh(NULL){
|
, mGeneratedMesh(nullptr){
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,7 +196,10 @@ void PLYImporter::InternReadFile(const std::string& pFile,
|
||||||
if (!PLY::DOM::ParseInstance(streamedBuffer, &sPlyDom, this))
|
if (!PLY::DOM::ParseInstance(streamedBuffer, &sPlyDom, this))
|
||||||
{
|
{
|
||||||
if (mGeneratedMesh != NULL)
|
if (mGeneratedMesh != NULL)
|
||||||
|
{
|
||||||
delete(mGeneratedMesh);
|
delete(mGeneratedMesh);
|
||||||
|
mGeneratedMesh = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
streamedBuffer.close();
|
streamedBuffer.close();
|
||||||
throw DeadlyImportError("Invalid .ply file: Unable to build DOM (#1)");
|
throw DeadlyImportError("Invalid .ply file: Unable to build DOM (#1)");
|
||||||
|
@ -211,7 +214,10 @@ void PLYImporter::InternReadFile(const std::string& pFile,
|
||||||
if (!PLY::DOM::ParseInstanceBinary(streamedBuffer, &sPlyDom, this, bIsBE))
|
if (!PLY::DOM::ParseInstanceBinary(streamedBuffer, &sPlyDom, this, bIsBE))
|
||||||
{
|
{
|
||||||
if (mGeneratedMesh != NULL)
|
if (mGeneratedMesh != NULL)
|
||||||
|
{
|
||||||
delete(mGeneratedMesh);
|
delete(mGeneratedMesh);
|
||||||
|
mGeneratedMesh = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
streamedBuffer.close();
|
streamedBuffer.close();
|
||||||
throw DeadlyImportError("Invalid .ply file: Unable to build DOM (#2)");
|
throw DeadlyImportError("Invalid .ply file: Unable to build DOM (#2)");
|
||||||
|
@ -220,7 +226,10 @@ void PLYImporter::InternReadFile(const std::string& pFile,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (mGeneratedMesh != NULL)
|
if (mGeneratedMesh != NULL)
|
||||||
|
{
|
||||||
delete(mGeneratedMesh);
|
delete(mGeneratedMesh);
|
||||||
|
mGeneratedMesh = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
streamedBuffer.close();
|
streamedBuffer.close();
|
||||||
throw DeadlyImportError("Invalid .ply file: Unknown file format");
|
throw DeadlyImportError("Invalid .ply file: Unknown file format");
|
||||||
|
@ -230,7 +239,10 @@ void PLYImporter::InternReadFile(const std::string& pFile,
|
||||||
{
|
{
|
||||||
AI_DEBUG_INVALIDATE_PTR(this->mBuffer);
|
AI_DEBUG_INVALIDATE_PTR(this->mBuffer);
|
||||||
if (mGeneratedMesh != NULL)
|
if (mGeneratedMesh != NULL)
|
||||||
|
{
|
||||||
delete(mGeneratedMesh);
|
delete(mGeneratedMesh);
|
||||||
|
mGeneratedMesh = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
streamedBuffer.close();
|
streamedBuffer.close();
|
||||||
throw DeadlyImportError("Invalid .ply file: Missing format specification");
|
throw DeadlyImportError("Invalid .ply file: Missing format specification");
|
||||||
|
@ -252,7 +264,10 @@ void PLYImporter::InternReadFile(const std::string& pFile,
|
||||||
if (mGeneratedMesh->mNumVertices < 3)
|
if (mGeneratedMesh->mNumVertices < 3)
|
||||||
{
|
{
|
||||||
if (mGeneratedMesh != NULL)
|
if (mGeneratedMesh != NULL)
|
||||||
|
{
|
||||||
delete(mGeneratedMesh);
|
delete(mGeneratedMesh);
|
||||||
|
mGeneratedMesh = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
streamedBuffer.close();
|
streamedBuffer.close();
|
||||||
throw DeadlyImportError("Invalid .ply file: Not enough "
|
throw DeadlyImportError("Invalid .ply file: Not enough "
|
||||||
|
@ -289,6 +304,7 @@ void PLYImporter::InternReadFile(const std::string& pFile,
|
||||||
pScene->mNumMeshes = 1;
|
pScene->mNumMeshes = 1;
|
||||||
pScene->mMeshes = new aiMesh*[pScene->mNumMeshes];
|
pScene->mMeshes = new aiMesh*[pScene->mNumMeshes];
|
||||||
pScene->mMeshes[0] = mGeneratedMesh;
|
pScene->mMeshes[0] = mGeneratedMesh;
|
||||||
|
mGeneratedMesh = nullptr;
|
||||||
|
|
||||||
// generate a simple node structure
|
// generate a simple node structure
|
||||||
pScene->mRootNode = new aiNode();
|
pScene->mRootNode = new aiNode();
|
||||||
|
|
Loading…
Reference in New Issue