From f8ae28578f794ac4ab122193f32f8810dca15ad7 Mon Sep 17 00:00:00 2001 From: jean-pierre charras <jp.charras@wanadoo.fr> Date: Mon, 30 Dec 2024 11:47:30 +0100 Subject: [PATCH] SHAPE_LINE_CHAIN() ctor: ensure arc info exists before trying to add it Fixes https://gitlab.com/kicad/code/kicad/-/issues/19419 --- libs/kimath/src/geometry/shape_line_chain.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libs/kimath/src/geometry/shape_line_chain.cpp b/libs/kimath/src/geometry/shape_line_chain.cpp index 4264a99b9a..adf63ea1a3 100644 --- a/libs/kimath/src/geometry/shape_line_chain.cpp +++ b/libs/kimath/src/geometry/shape_line_chain.cpp @@ -108,8 +108,14 @@ SHAPE_LINE_CHAIN::SHAPE_LINE_CHAIN( const Clipper2Lib::Path64& aPath, { Append( aPath[ii].x, aPath[ii].y ); - m_shapes[ii].first = loadArc( aZValueBuffer[aPath[ii].z].m_FirstArcIdx ); - m_shapes[ii].second = loadArc( aZValueBuffer[aPath[ii].z].m_SecondArcIdx ); + // Add arc info (if exists) + int idx_z = aPath[ii].z; + + if( idx_z < 0 || idx_z >= (int)aZValueBuffer.size() ) + continue; + + m_shapes[ii].first = loadArc( aZValueBuffer[idx_z].m_FirstArcIdx ); + m_shapes[ii].second = loadArc( aZValueBuffer[idx_z].m_SecondArcIdx ); } // Clipper shouldn't return duplicate contiguous points. if it did, these would be