From f2edf02b353cfc4f8fa5c9feb435b792dd3b14b1 Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Sun, 15 Feb 2015 19:04:48 -0500 Subject: [PATCH] Coverity error fixes. * Fix unitialized variable in MSG_PANEL_ITEM default ctor. * Fix a bunch of uncaught exception issues. * Fix a memory leak in the NETLIST_READER::GetNetlistReader() when an an attempt to read an invalid net list file occurs. --- include/msgpanel.h | 3 ++- pcbnew/github/github_plugin.cpp | 2 +- pcbnew/github/github_plugin.h | 2 +- pcbnew/netlist_reader.cpp | 2 +- pcbnew/specctra.cpp | 21 +++++++++++---------- pcbnew/specctra.h | 20 ++++++++++---------- 6 files changed, 26 insertions(+), 24 deletions(-) diff --git a/include/msgpanel.h b/include/msgpanel.h index dc5edd29eb..f2cfe16e3a 100644 --- a/include/msgpanel.h +++ b/include/msgpanel.h @@ -71,7 +71,8 @@ public: { } - MSG_PANEL_ITEM() + MSG_PANEL_ITEM() : + m_Pad( MSG_PANEL_DEFAULT_PAD ) { } diff --git a/pcbnew/github/github_plugin.cpp b/pcbnew/github/github_plugin.cpp index 4f86c13d5a..0283723431 100644 --- a/pcbnew/github/github_plugin.cpp +++ b/pcbnew/github/github_plugin.cpp @@ -379,7 +379,7 @@ void GITHUB_PLUGIN::FootprintLibOptions( PROPERTIES* aListToAppendTo ) const } -void GITHUB_PLUGIN::cacheLib( const wxString& aLibraryPath, const PROPERTIES* aProperties ) throw( IO_ERROR ) +void GITHUB_PLUGIN::cacheLib( const wxString& aLibraryPath, const PROPERTIES* aProperties ) { // This is edge triggered based on a change in 'aLibraryPath', // usually it does nothing. When the edge fires, m_pretty_dir is set diff --git a/pcbnew/github/github_plugin.h b/pcbnew/github/github_plugin.h index 01eb5047e4..5a041d0581 100644 --- a/pcbnew/github/github_plugin.h +++ b/pcbnew/github/github_plugin.h @@ -200,7 +200,7 @@ protected: void init( const PROPERTIES* aProperties ); - void cacheLib( const wxString& aLibraryPath, const PROPERTIES* aProperties ) throw( IO_ERROR ); + void cacheLib( const wxString& aLibraryPath, const PROPERTIES* aProperties ); /** * Function repoURL_zipURL diff --git a/pcbnew/netlist_reader.cpp b/pcbnew/netlist_reader.cpp index 1a2978cf25..a7e278a035 100644 --- a/pcbnew/netlist_reader.cpp +++ b/pcbnew/netlist_reader.cpp @@ -126,9 +126,9 @@ NETLIST_READER* NETLIST_READER::GetNetlistReader( NETLIST* aNetlist, default: // Unrecognized format: break; - } + delete cmpFileReader; return NULL; } diff --git a/pcbnew/specctra.cpp b/pcbnew/specctra.cpp index b2ecc0ab7f..91b13ccc82 100644 --- a/pcbnew/specctra.cpp +++ b/pcbnew/specctra.cpp @@ -602,7 +602,8 @@ void SPECCTRA_DB::doLAYER_PAIR( LAYER_PAIR* growth ) throw( IO_ERROR ) } -void SPECCTRA_DB::doLAYER_NOISE_WEIGHT( LAYER_NOISE_WEIGHT* growth ) throw( IO_ERROR ) +void SPECCTRA_DB::doLAYER_NOISE_WEIGHT( LAYER_NOISE_WEIGHT* growth ) + throw( IO_ERROR, boost::bad_pointer ) { T tok; @@ -755,7 +756,7 @@ L_place: } -void SPECCTRA_DB::doSTRUCTURE_OUT( STRUCTURE_OUT* growth ) throw( IO_ERROR ) +void SPECCTRA_DB::doSTRUCTURE_OUT( STRUCTURE_OUT* growth ) throw( IO_ERROR, boost::bad_pointer ) { /* ::= @@ -1862,7 +1863,7 @@ void SPECCTRA_DB::doPLACE( PLACE* growth ) throw( IO_ERROR ) } -void SPECCTRA_DB::doCOMPONENT( COMPONENT* growth ) throw( IO_ERROR ) +void SPECCTRA_DB::doCOMPONENT( COMPONENT* growth ) throw( IO_ERROR, boost::bad_pointer ) { T tok = NextTok(); @@ -2130,7 +2131,7 @@ L_done_that: } -void SPECCTRA_DB::doIMAGE( IMAGE* growth ) throw( IO_ERROR ) +void SPECCTRA_DB::doIMAGE( IMAGE* growth ) throw( IO_ERROR, boost::bad_pointer ) { T tok = NextTok(); @@ -2327,7 +2328,7 @@ void SPECCTRA_DB::doLIBRARY( LIBRARY* growth ) throw( IO_ERROR ) } -void SPECCTRA_DB::doNET( NET* growth ) throw( IO_ERROR ) +void SPECCTRA_DB::doNET( NET* growth ) throw( IO_ERROR, boost::bad_pointer ) { T tok = NextTok(); PIN_REFS* pin_refs; @@ -2615,7 +2616,7 @@ void SPECCTRA_DB::doCLASS( CLASS* growth ) throw( IO_ERROR ) } -void SPECCTRA_DB::doNETWORK( NETWORK* growth ) throw( IO_ERROR ) +void SPECCTRA_DB::doNETWORK( NETWORK* growth ) throw( IO_ERROR, boost::bad_pointer ) { T tok; @@ -2764,7 +2765,7 @@ void SPECCTRA_DB::doFROMTO( FROMTO* growth ) throw( IO_ERROR ) } -void SPECCTRA_DB::doWIRE( WIRE* growth ) throw( IO_ERROR ) +void SPECCTRA_DB::doWIRE( WIRE* growth ) throw( IO_ERROR, boost::bad_pointer ) { T tok; @@ -3083,7 +3084,7 @@ void SPECCTRA_DB::doANCESTOR( ANCESTOR* growth ) throw( IO_ERROR ) } -void SPECCTRA_DB::doHISTORY( HISTORY* growth ) throw( IO_ERROR ) +void SPECCTRA_DB::doHISTORY( HISTORY* growth ) throw( IO_ERROR, boost::bad_pointer ) { T tok; @@ -3257,7 +3258,7 @@ void SPECCTRA_DB::doWAS_IS( WAS_IS* growth ) throw( IO_ERROR ) } -void SPECCTRA_DB::doROUTE( ROUTE* growth ) throw( IO_ERROR ) +void SPECCTRA_DB::doROUTE( ROUTE* growth ) throw( IO_ERROR, boost::bad_pointer ) { T tok; @@ -3340,7 +3341,7 @@ void SPECCTRA_DB::doROUTE( ROUTE* growth ) throw( IO_ERROR ) } -void SPECCTRA_DB::doNET_OUT( NET_OUT* growth ) throw( IO_ERROR ) +void SPECCTRA_DB::doNET_OUT( NET_OUT* growth ) throw( IO_ERROR, boost::bad_pointer ) { T tok; diff --git a/pcbnew/specctra.h b/pcbnew/specctra.h index 5766cc7fb8..b56c483333 100644 --- a/pcbnew/specctra.h +++ b/pcbnew/specctra.h @@ -3695,8 +3695,8 @@ class SPECCTRA_DB : public SPECCTRA_LEXER void doRESOLUTION( UNIT_RES* growth ) throw( IO_ERROR ); void doUNIT( UNIT_RES* growth ) throw( IO_ERROR ); void doSTRUCTURE( STRUCTURE* growth ) throw( IO_ERROR ); - void doSTRUCTURE_OUT( STRUCTURE_OUT* growth ) throw( IO_ERROR ); - void doLAYER_NOISE_WEIGHT( LAYER_NOISE_WEIGHT* growth ) throw( IO_ERROR ); + void doSTRUCTURE_OUT( STRUCTURE_OUT* growth ) throw( IO_ERROR, boost::bad_pointer ); + void doLAYER_NOISE_WEIGHT( LAYER_NOISE_WEIGHT* growth ) throw( IO_ERROR, boost::bad_pointer ); void doLAYER_PAIR( LAYER_PAIR* growth ) throw( IO_ERROR ); void doBOUNDARY( BOUNDARY* growth ) throw( IO_ERROR ); void doRECTANGLE( RECTANGLE* growth ) throw( IO_ERROR ); @@ -3718,29 +3718,29 @@ class SPECCTRA_DB : public SPECCTRA_LEXER void doCLASSES( CLASSES* growth ) throw( IO_ERROR ); void doGRID( GRID* growth ) throw( IO_ERROR ); void doPLACE( PLACE* growth ) throw( IO_ERROR ); - void doCOMPONENT( COMPONENT* growth ) throw( IO_ERROR ); + void doCOMPONENT( COMPONENT* growth ) throw( IO_ERROR, boost::bad_pointer ); void doPLACEMENT( PLACEMENT* growth ) throw( IO_ERROR ); void doPROPERTIES( PROPERTIES* growth ) throw( IO_ERROR ); void doPADSTACK( PADSTACK* growth ) throw( IO_ERROR ); void doSHAPE( SHAPE* growth ) throw( IO_ERROR ); - void doIMAGE( IMAGE* growth ) throw( IO_ERROR ); + void doIMAGE( IMAGE* growth ) throw( IO_ERROR, boost::bad_pointer ); void doLIBRARY( LIBRARY* growth ) throw( IO_ERROR ); void doPIN( PIN* growth ) throw( IO_ERROR ); - void doNET( NET* growth ) throw( IO_ERROR ); - void doNETWORK( NETWORK* growth ) throw( IO_ERROR ); + void doNET( NET* growth ) throw( IO_ERROR, boost::bad_pointer ); + void doNETWORK( NETWORK* growth ) throw( IO_ERROR, boost::bad_pointer ); void doCLASS( CLASS* growth ) throw( IO_ERROR ); void doTOPOLOGY( TOPOLOGY* growth ) throw( IO_ERROR ); void doFROMTO( FROMTO* growth ) throw( IO_ERROR ); void doCOMP_ORDER( COMP_ORDER* growth ) throw( IO_ERROR ); - void doWIRE( WIRE* growth ) throw( IO_ERROR ); + void doWIRE( WIRE* growth ) throw( IO_ERROR, boost::bad_pointer ); void doWIRE_VIA( WIRE_VIA* growth ) throw( IO_ERROR ); void doWIRING( WIRING* growth ) throw( IO_ERROR ); void doSESSION( SESSION* growth ) throw( IO_ERROR ); void doANCESTOR( ANCESTOR* growth ) throw( IO_ERROR ); - void doHISTORY( HISTORY* growth ) throw( IO_ERROR ); - void doROUTE( ROUTE* growth ) throw( IO_ERROR ); + void doHISTORY( HISTORY* growth ) throw( IO_ERROR, boost::bad_pointer ); + void doROUTE( ROUTE* growth ) throw( IO_ERROR, boost::bad_pointer ); void doWAS_IS( WAS_IS* growth ) throw( IO_ERROR ); - void doNET_OUT( NET_OUT* growth ) throw( IO_ERROR ); + void doNET_OUT( NET_OUT* growth ) throw( IO_ERROR, boost::bad_pointer ); void doSUPPLY_PIN( SUPPLY_PIN* growth ) throw( IO_ERROR ); //------------------------------------------------------------