From 9ddb4fe67e8707e2310773bc871fcc7c699ea25f Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Tue, 14 Mar 2017 18:54:40 -0400 Subject: [PATCH] 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 --- common/fp_lib_table.cpp | 11 +++++----- common/lib_table_base.cpp | 2 -- eeschema/symbol_lib_table.cpp | 10 ++++----- eeschema/symbol_lib_table.h | 6 ++---- include/fp_lib_table.h | 4 ++-- include/lib_table_base.h | 38 +++++++++++++++++++++++++++-------- 6 files changed, 43 insertions(+), 28 deletions(-) diff --git a/common/fp_lib_table.cpp b/common/fp_lib_table.cpp index edd9031993..4c4f6e203f 100644 --- a/common/fp_lib_table.cpp +++ b/common/fp_lib_table.cpp @@ -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" ); } diff --git a/common/lib_table_base.cpp b/common/lib_table_base.cpp index 0e0a0da3a9..422f74cef2 100644 --- a/common/lib_table_base.cpp +++ b/common/lib_table_base.cpp @@ -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)) diff --git a/eeschema/symbol_lib_table.cpp b/eeschema/symbol_lib_table.cpp index 9be4159628..1d71216b2e 100644 --- a/eeschema/symbol_lib_table.cpp +++ b/eeschema/symbol_lib_table.cpp @@ -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" ); } diff --git a/eeschema/symbol_lib_table.h b/eeschema/symbol_lib_table.h index 58d715e8b4..03dc99d758 100644 --- a/eeschema/symbol_lib_table.h +++ b/eeschema/symbol_lib_table.h @@ -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 diff --git a/include/fp_lib_table.h b/include/fp_lib_table.h index 572185ff99..9162aae4f4 100644 --- a/include/fp_lib_table.h +++ b/include/fp_lib_table.h @@ -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 diff --git a/include/lib_table_base.h b/include/lib_table_base.h index 717c31f642..381e0f7eef 100644 --- a/include/lib_table_base.h +++ b/include/lib_table_base.h @@ -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