Fix crash when converting a Eagle board to a Kicad board.

During conversion a illegal layer number was used without filtering
This commit is contained in:
jean-pierre charras 2020-11-17 10:23:44 +01:00
parent 7d1a4a4224
commit a431fd99ca
2 changed files with 10 additions and 10 deletions

View File

@ -785,7 +785,10 @@ public:
*/
inline bool IsLayerEnabled( PCB_LAYER_ID aLayerId ) const
{
return m_enabledLayers[aLayerId];
if( aLayerId >= 0 && aLayerId < PCB_LAYER_ID_COUNT )
return m_enabledLayers[aLayerId];
return false;
}
/**

View File

@ -530,12 +530,7 @@ void EAGLE_PLUGIN::loadLayerDefs( wxXmlNode* aLayers )
else
{
// some eagle boards do not have contiguous layer number sequences.
#if 0 // pre PCB_LAYER_ID & LSET:
m_cu_map[it->number] = cu.size() - 1 - ki_layer_count;
#else
m_cu_map[it->number] = ki_layer_count;
#endif
}
}
@ -548,10 +543,12 @@ void EAGLE_PLUGIN::loadLayerDefs( wxXmlNode* aLayers )
{
PCB_LAYER_ID layer = kicad_layer( it->number );
// these function provide their own protection against UNDEFINED_LAYER:
m_board->SetLayerName( layer, FROM_UTF8( it->name.c_str() ) );
m_board->SetLayerType( layer, LT_SIGNAL );
// these function provide their own protection against non enabled layers:
if( layer >= 0 && layer < PCB_LAYER_ID_COUNT ) // layer should be valid
{
m_board->SetLayerName( layer, FROM_UTF8( it->name.c_str() ) );
m_board->SetLayerType( layer, LT_SIGNAL );
}
// could map the colors here
}
}