From 7d69a917b931552f9f1a3131ad12bf3007605704 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Fri, 14 Jun 2019 13:00:39 +0200 Subject: [PATCH] Fixed a crash in EE_SELECTION_TOOL::SelectPoint() The for loop is continued after an item removal, so the removed item is not accessed anymore. --- eeschema/tools/ee_selection_tool.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/eeschema/tools/ee_selection_tool.cpp b/eeschema/tools/ee_selection_tool.cpp index 1936c5e185..ee4ca95e32 100644 --- a/eeschema/tools/ee_selection_tool.cpp +++ b/eeschema/tools/ee_selection_tool.cpp @@ -486,16 +486,22 @@ EDA_ITEM* EE_SELECTION_TOOL::SelectPoint( const VECTOR2I& aWhere, const KICAD_T* collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) ); collector.Collect( start, aFilterList, (wxPoint) aWhere, m_unit, m_convert ); - bool anyCollected = collector.GetCount() != 0; + bool anyCollected = collector.GetCount() > 0; // Post-process collected items for( int i = collector.GetCount() - 1; i >= 0; --i ) { if( !selectable( collector[ i ] ) ) + { collector.Remove( i ); + continue; + } if( aCheckLocked && collector[ i ]->IsLocked() ) + { collector.Remove( i ); + continue; + } // SelectPoint, unlike other selection routines, can select line ends if( collector[ i ]->Type() == SCH_LINE_T )