From 63eac0382c5c282928d402fc3f62b4b2692bf958 Mon Sep 17 00:00:00 2001 From: Alex Shvartzkop Date: Fri, 19 Jul 2024 01:56:09 +0300 Subject: [PATCH] Add bounds checking when slicing SHAPE_LINE_CHAIN from the middle of the last arc. (and said arc is the last shape in the chain) Fixes https://gitlab.com/kicad/code/kicad/-/issues/18391 --- libs/kimath/src/geometry/shape_line_chain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/kimath/src/geometry/shape_line_chain.cpp b/libs/kimath/src/geometry/shape_line_chain.cpp index f54215ec0e..bcf91f629f 100644 --- a/libs/kimath/src/geometry/shape_line_chain.cpp +++ b/libs/kimath/src/geometry/shape_line_chain.cpp @@ -1481,7 +1481,7 @@ const SHAPE_LINE_CHAIN SHAPE_LINE_CHAIN::Slice( int aStartIndex, int aEndIndex ) const SHAPE_ARC& arcToSplit = Arc( arcToSplitIndex ); // Copy the points as arc points - for( size_t i = aStartIndex; arcToSplitIndex == ArcIndex( i ); i++ ) + for( size_t i = aStartIndex; i < m_points.size() && arcToSplitIndex == ArcIndex( i ); i++ ) { rv.m_points.push_back( m_points[i] ); rv.m_shapes.push_back( { rv.m_arcs.size(), SHAPE_IS_PT } );