XFileParser: release x-file-based scene when throwing an exception.

This commit is contained in:
Kim Kulling
2018-02-06 19:21:56 +01:00
parent dceb7257dd
commit 495ae70cc5
6 changed files with 243 additions and 236 deletions

View File

@@ -1047,8 +1047,10 @@ void XFileParser::readHeadOfDataObject( std::string* poName)
if( poName)
*poName = nameOrBrace;
if( GetNextToken() != "{")
ThrowException( "Opening brace expected.");
if ( GetNextToken() != "{" ) {
delete mScene;
ThrowException( "Opening brace expected." );
}
}
}
@@ -1224,21 +1226,29 @@ void XFileParser::GetNextTokenAsString( std::string& poString)
}
FindNextNoneWhiteSpace();
if( mP >= mEnd)
ThrowException( "Unexpected end of file while parsing string");
if ( mP >= mEnd ) {
delete mScene;
ThrowException( "Unexpected end of file while parsing string" );
}
if( *mP != '"')
ThrowException( "Expected quotation mark.");
if ( *mP != '"' ) {
delete mScene;
ThrowException( "Expected quotation mark." );
}
++mP;
while( mP < mEnd && *mP != '"')
poString.append( mP++, 1);
if( mP >= mEnd-1)
ThrowException( "Unexpected end of file while parsing string");
if ( mP >= mEnd - 1 ) {
delete mScene;
ThrowException( "Unexpected end of file while parsing string" );
}
if( mP[1] != ';' || mP[0] != '"')
ThrowException( "Expected quotation mark and semicolon at the end of a string.");
if ( mP[ 1 ] != ';' || mP[ 0 ] != '"' ) {
delete mScene;
ThrowException( "Expected quotation mark and semicolon at the end of a string." );
}
mP+=2;
}
@@ -1449,15 +1459,15 @@ aiColor3D XFileParser::ReadRGB()
// ------------------------------------------------------------------------------------------------
// Throws an exception with a line number and the given text.
AI_WONT_RETURN void XFileParser::ThrowException( const std::string& pText)
{
if( mIsBinaryFormat)
throw DeadlyImportError( pText);
else
AI_WONT_RETURN void XFileParser::ThrowException( const std::string& pText) {
delete mScene;
if ( mIsBinaryFormat ) {
throw DeadlyImportError( pText );
} else {
throw DeadlyImportError( format() << "Line " << mLineNumber << ": " << pText );
}
}
// ------------------------------------------------------------------------------------------------
// Filters the imported hierarchy for some degenerated cases that some exporters produce.
void XFileParser::FilterHierarchy( XFile::Node* pNode)