From 3fa8795f261882bd31fd0c7ddd94bb7602b81fcc Mon Sep 17 00:00:00 2001 From: Roberto Fernandez Bautista Date: Fri, 28 May 2021 19:41:53 +0100 Subject: [PATCH] Fix crash in LIBEDIT when editing pins Units in library items start at 1. 0 is reserved for "all units". Previous code was requesting an out of range index due to an assumption that units start at 0. --- eeschema/tools/symbol_editor_pin_tool.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/eeschema/tools/symbol_editor_pin_tool.cpp b/eeschema/tools/symbol_editor_pin_tool.cpp index 85112a4611..16a1d9321f 100644 --- a/eeschema/tools/symbol_editor_pin_tool.cpp +++ b/eeschema/tools/symbol_editor_pin_tool.cpp @@ -139,7 +139,7 @@ bool SYMBOL_EDITOR_PIN_TOOL::EditPinProperties( LIB_PIN* aPin ) aPin->GetParent()->GetPins( pinList ); std::vector got_unit( aPin->GetParent()->GetUnitCount() ); - got_unit[aPin->GetUnit()] = true; + got_unit[static_cast(aPin->GetUnit()) - 1] = true; for( LIB_PIN* other : pinList ) { @@ -149,7 +149,7 @@ bool SYMBOL_EDITOR_PIN_TOOL::EditPinProperties( LIB_PIN* aPin ) /// Only change one pin per unit to allow stacking pins /// If you change all units on the position, then pins are not /// uniquely editable - if( got_unit[other->GetUnit()] ) + if( got_unit[static_cast( other->GetUnit() ) - 1] ) continue; if( other->GetPosition() == original_pin.GetPosition() @@ -184,7 +184,7 @@ bool SYMBOL_EDITOR_PIN_TOOL::EditPinProperties( LIB_PIN* aPin ) other->SetNumberTextSize( aPin->GetNumberTextSize() ); other->SetModified(); - got_unit[other->GetUnit()] = true; + got_unit[static_cast( other->GetUnit() ) - 1] = true; } } }