Fix crash in libedit when moving/editing pins in synchronised mode

Unit numbers start at 1, not 0. Our vector needs to be size + 1 if we want
to use the unit number as an index.
0 is reserved for "all units"
This commit is contained in:
Roberto Fernandez Bautista 2021-10-30 13:52:13 +01:00
parent b2db24f275
commit c5cdda26ae
3 changed files with 3 additions and 3 deletions

View File

@ -275,7 +275,7 @@ int SYMBOL_EDITOR_EDIT_TOOL::DoDelete( const TOOL_EVENT& aEvent )
// in different units are also removed. But only one pin per unit (matching)
if( m_frame->SynchronizePins() )
{
std::vector<bool> got_unit( symbol->GetUnitCount() );
std::vector<bool> got_unit( symbol->GetUnitCount() + 1 );
got_unit[pin->GetUnit()] = true;

View File

@ -156,7 +156,7 @@ int SYMBOL_EDITOR_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
{
LIB_PIN* cur_pin = static_cast<LIB_PIN*>( lib_item );
LIB_SYMBOL* symbol = m_frame->GetCurSymbol();
std::vector<bool> got_unit( symbol->GetUnitCount() );
std::vector<bool> got_unit( symbol->GetUnitCount() + 1 );
got_unit[cur_pin->GetUnit()] = true;

View File

@ -142,7 +142,7 @@ bool SYMBOL_EDITOR_PIN_TOOL::EditPinProperties( LIB_PIN* aPin )
// a pin can have a unit id = 0 (common to all units) to unit count
// So we need a buffer size = GetUnitCount()+1 to store a value in a vector
// when using the unit id of a pin as index
std::vector<bool> got_unit( aPin->GetParent()->GetUnitCount()+1 );
std::vector<bool> got_unit( aPin->GetParent()->GetUnitCount() + 1 );
got_unit[static_cast<size_t>(aPin->GetUnit())] = true;