From b4c826b90449fadc193e296431b15beab0638340 Mon Sep 17 00:00:00 2001 From: aramis_acg Date: Thu, 7 Aug 2008 20:52:25 +0000 Subject: [PATCH] Minor bugfix to the PLY loader git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@79 67173fc5-114c-0410-ac8e-9d2fd5bffc1f --- code/PlyLoader.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/code/PlyLoader.cpp b/code/PlyLoader.cpp index aa3b2d6d6..8d333c07e 100644 --- a/code/PlyLoader.cpp +++ b/code/PlyLoader.cpp @@ -104,7 +104,7 @@ void PLYImporter::InternReadFile( size_t fileSize = file->FileSize(); if( fileSize < 10) { - throw new ImportErrorException( ".ply File is too small."); + throw new ImportErrorException( "PLY File is too small."); } // allocate storage and copy the contents of the file to a memory buffer @@ -121,6 +121,7 @@ void PLYImporter::InternReadFile( this->mBuffer[2] != 'Y' && this->mBuffer[2] != 'y') { delete[] this->mBuffer; + AI_DEBUG_INVALIDATE_PTR(this->mBuffer); throw new ImportErrorException( "Invalid .ply file: Magic number \'ply\' is no there"); } char* szMe = (char*)&this->mBuffer[3]; @@ -138,6 +139,7 @@ void PLYImporter::InternReadFile( if(!PLY::DOM::ParseInstance(szMe,&sPlyDom)) { delete[] this->mBuffer; + AI_DEBUG_INVALIDATE_PTR(this->mBuffer); throw new ImportErrorException( "Invalid .ply file: Unable to build DOM (#1)"); } } @@ -159,18 +161,21 @@ void PLYImporter::InternReadFile( if(!PLY::DOM::ParseInstanceBinary(szMe,&sPlyDom,bIsBE)) { delete[] this->mBuffer; + AI_DEBUG_INVALIDATE_PTR(this->mBuffer); throw new ImportErrorException( "Invalid .ply file: Unable to build DOM (#2)"); } } else { delete[] this->mBuffer; + AI_DEBUG_INVALIDATE_PTR(this->mBuffer); throw new ImportErrorException( "Invalid .ply file: Unknown file format"); } } else { delete[] this->mBuffer; + AI_DEBUG_INVALIDATE_PTR(this->mBuffer); throw new ImportErrorException( "Invalid .ply file: Missing format specification"); } this->pcDOM = &sPlyDom; @@ -181,7 +186,10 @@ void PLYImporter::InternReadFile( if (avPositions.empty()) { - throw new ImportErrorException( "Invalid .ply file: No vertices found"); + delete[] this->mBuffer; + AI_DEBUG_INVALIDATE_PTR(this->mBuffer); + throw new ImportErrorException( "Invalid .ply file: No vertices found. " + "Unable to interpret the data format of the PLY file"); } // now load a list of normals. @@ -199,6 +207,7 @@ void PLYImporter::InternReadFile( if (avPositions.size() < 3) { delete[] this->mBuffer; + AI_DEBUG_INVALIDATE_PTR(this->mBuffer); throw new ImportErrorException( "Invalid .ply file: Not enough vertices to build " "a face list. "); } @@ -237,6 +246,7 @@ void PLYImporter::InternReadFile( if (avMeshes.empty()) { delete[] this->mBuffer; + AI_DEBUG_INVALIDATE_PTR(this->mBuffer); throw new ImportErrorException( "Invalid .ply file: Unable to extract mesh data "); } @@ -261,7 +271,7 @@ void PLYImporter::InternReadFile( pScene->mRootNode->mMeshes[i] = i; // delete the file buffer - delete[] this->mBuffer; + delete[] this->mBuffer;AI_DEBUG_INVALIDATE_PTR(this->mBuffer); // DOM is lying on the stack, will be deconstructed automatically return;