Fix uncaught exception in footprint and symbol library table parsers.

Fixes Coverity CID 154580
Fixes Coverity CID 154581
Fixes Coverity CID 154582
Fixes Coverity CID 154583
Fixes Coverity CID 154584
Fixes Coverity CID 154585
This commit is contained in:
Wayne Stambaugh 2017-03-14 18:54:40 -04:00
parent 996cba7e7f
commit 9ddb4fe67e
6 changed files with 43 additions and 28 deletions

View File

@ -64,7 +64,7 @@ FP_LIB_TABLE::FP_LIB_TABLE( FP_LIB_TABLE* aFallBackTable ) :
}
void FP_LIB_TABLE::Parse( LIB_TABLE_LEXER* in ) throw()
void FP_LIB_TABLE::Parse( LIB_TABLE_LEXER* in )
{
T tok;
@ -185,15 +185,14 @@ void FP_LIB_TABLE::Parse( LIB_TABLE_LEXER* in ) throw()
}
void FP_LIB_TABLE::Format( OUTPUTFORMATTER* out, int nestLevel ) const
throw()
void FP_LIB_TABLE::Format( OUTPUTFORMATTER* aOutput, int aIndentLevel ) const
{
out->Print( nestLevel, "(fp_lib_table\n" );
aOutput->Print( aIndentLevel, "(fp_lib_table\n" );
for( LIB_TABLE_ROWS_CITER it = rows.begin(); it != rows.end(); ++it )
it->Format( out, nestLevel+1 );
it->Format( aOutput, aIndentLevel+1 );
out->Print( nestLevel, ")\n" );
aOutput->Print( aIndentLevel, ")\n" );
}

View File

@ -81,7 +81,6 @@ const wxString LIB_TABLE_ROW::GetFullURI( bool aSubstituted ) const
void LIB_TABLE_ROW::Format( OUTPUTFORMATTER* out, int nestLevel ) const
throw( IO_ERROR, boost::interprocess::lock_exception )
{
// In Kicad, we save path and file names using the Unix notation (separator = '/')
// So ensure separator is always '/' is saved URI string
@ -99,7 +98,6 @@ void LIB_TABLE_ROW::Format( OUTPUTFORMATTER* out, int nestLevel ) const
void LIB_TABLE_ROW::Parse( std::unique_ptr< LIB_TABLE_ROW >& aRow, LIB_TABLE_LEXER* in )
throw( IO_ERROR, PARSE_ERROR )
{
/*
* (lib (name NICKNAME)(descr DESCRIPTION)(type TYPE)(full_uri FULL_URI)(options OPTIONS))

View File

@ -67,7 +67,6 @@ SYMBOL_LIB_TABLE::SYMBOL_LIB_TABLE( SYMBOL_LIB_TABLE* aFallBackTable ) :
void SYMBOL_LIB_TABLE::Parse( LIB_TABLE_LEXER* in )
throw( IO_ERROR, PARSE_ERROR )
{
T tok;
@ -188,15 +187,14 @@ void SYMBOL_LIB_TABLE::Parse( LIB_TABLE_LEXER* in )
}
void SYMBOL_LIB_TABLE::Format( OUTPUTFORMATTER* out, int nestLevel ) const
throw( IO_ERROR, boost::interprocess::lock_exception )
void SYMBOL_LIB_TABLE::Format( OUTPUTFORMATTER* aOutput, int aIndentLevel ) const
{
out->Print( nestLevel, "(sym_lib_table\n" );
aOutput->Print( aIndentLevel, "(sym_lib_table\n" );
for( LIB_TABLE_ROWS_CITER it = rows.begin(); it != rows.end(); ++it )
it->Format( out, nestLevel+1 );
it->Format( aOutput, aIndentLevel+1 );
out->Print( nestLevel, ")\n" );
aOutput->Print( aIndentLevel, ")\n" );
}

View File

@ -101,11 +101,9 @@ class SYMBOL_LIB_TABLE : public LIB_TABLE
{
public:
virtual void Parse( LIB_TABLE_LEXER* aLexer )
throw( IO_ERROR, PARSE_ERROR ) override;
virtual void Parse( LIB_TABLE_LEXER* aLexer ) override;
virtual void Format( OUTPUTFORMATTER* out, int nestLevel ) const
throw( IO_ERROR, boost::interprocess::lock_exception ) override;
virtual void Format( OUTPUTFORMATTER* aOutput, int aIndentLevel ) const override;
/**
* Constructor SYMBOL_LIB_TABLE

View File

@ -103,9 +103,9 @@ class FP_LIB_TABLE : public LIB_TABLE
{
public:
virtual void Parse( LIB_TABLE_LEXER* aLexer ) throw() override;
virtual void Parse( LIB_TABLE_LEXER* aLexer ) override;
virtual void Format( OUTPUTFORMATTER* out, int nestLevel ) const throw() override;
virtual void Format( OUTPUTFORMATTER* aOutput, int aIndentLevel ) const override;
/**
* Constructor FP_LIB_TABLE

View File

@ -178,11 +178,9 @@ public:
* @param nestLevel is the indentation level to base all lines of the output.
* Actual indentation will be 2 spaces for each nestLevel.
*/
void Format( OUTPUTFORMATTER* out, int nestLevel ) const
throw( IO_ERROR, boost::interprocess::lock_exception );
void Format( OUTPUTFORMATTER* out, int nestLevel ) const;
static void Parse( std::unique_ptr< LIB_TABLE_ROW >& aRow, LIB_TABLE_LEXER* in )
throw( IO_ERROR, PARSE_ERROR );
static void Parse( std::unique_ptr< LIB_TABLE_ROW >& aRow, LIB_TABLE_LEXER* in );
LIB_TABLE_ROW* clone() const
{
@ -279,11 +277,35 @@ class LIB_TABLE : public PROJECT::_ELEM
public:
virtual void Parse( LIB_TABLE_LEXER* aLexer )
throw( IO_ERROR, PARSE_ERROR ) = 0;
/**
* Function Parse
*
* Parses the \a #LIB_TABLE_LEXER s-expression library table format into the appropriate
* #LIB_TABLE_ROW objects.
*
* @param aLexer is the lexer to parse.
*
* @throw IO_ERROR if an I/O error occurs during parsing.
* @throw PARSER_ERROR if the lexer format to parse is invalid.
* @throw boost::bad_pointer if an any attempt to add an invalid pointer to the
* boost::ptr_vector.
* @throw boost::bad_index if an index outside the row table bounds is accessed.
*/
virtual void Parse( LIB_TABLE_LEXER* aLexer ) = 0;
virtual void Format( OUTPUTFORMATTER* out, int nestLevel ) const
throw( IO_ERROR, boost::interprocess::lock_exception ) = 0;
/**
* Function Format
*
* Generates the table s-expression format to the \a aOutput with an indention level
* of \a aIndentLevel.
*
* @param aOutput is the #OUTPUTFORMATER to format the table into.
* @param aIndentLevel is the indentation level (2 spaces) to indent.
*
* @throw IO_ERROR if an I/O error occurs during output.
* @throw boost::interprocess::lock_except if separate process attempt to access the table.
*/
virtual void Format( OUTPUTFORMATTER* aOutput, int aIndentLevel ) const = 0;
/**
* Constructor LIB_TABLE