From a744857267ca7b42fd0c66ed1ca76edac99104a3 Mon Sep 17 00:00:00 2001 From: Tomasz Wlostowski Date: Thu, 3 Jun 2021 22:33:38 +0200 Subject: [PATCH] router: fix array out-of-bound error in HullIntersection() fixes: https://gitlab.com/kicad/code/kicad/-/issues/8538 --- pcbnew/router/pns_utils.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pcbnew/router/pns_utils.cpp b/pcbnew/router/pns_utils.cpp index f155915461..57bf80f7da 100644 --- a/pcbnew/router/pns_utils.cpp +++ b/pcbnew/router/pns_utils.cpp @@ -271,7 +271,7 @@ void HullIntersection( const SHAPE_LINE_CHAIN& hull, const SHAPE_LINE_CHAIN& lin hull.Intersect( line, ips_raw ); - for( const auto& p : ips_raw ) + for( auto& p : ips_raw ) { SHAPE_LINE_CHAIN::INTERSECTION ipp; @@ -289,6 +289,9 @@ void HullIntersection( const SHAPE_LINE_CHAIN& hull, const SHAPE_LINE_CHAIN& lin continue; } + if( p.index_our >= hull.SegmentCount() ) + p.index_our -= hull.SegmentCount(); + if( p.is_corner_our ) { d1[0] = hull.CSegment( p.index_our ); @@ -340,4 +343,4 @@ void HullIntersection( const SHAPE_LINE_CHAIN& hull, const SHAPE_LINE_CHAIN& lin } } -} \ No newline at end of file +}