diff --git a/pcbnew/router/pns_line.cpp b/pcbnew/router/pns_line.cpp index b22ab3e11e..dfe2aa3fed 100644 --- a/pcbnew/router/pns_line.cpp +++ b/pcbnew/router/pns_line.cpp @@ -339,6 +339,7 @@ void LINE::ShowLinks() const wxLogTrace( "PNS", "seg %d: %p\n", i, m_segmentRefs[i] ); } + SHAPE_LINE_CHAIN dragCornerInternal( const SHAPE_LINE_CHAIN& aOrigin, const VECTOR2I& aP ) { OPT picked; @@ -362,14 +363,21 @@ SHAPE_LINE_CHAIN dragCornerInternal( const SHAPE_LINE_CHAIN& aOrigin, const VECT SHAPE_LINE_CHAIN paths[2]; DIRECTION_45 dirs[2]; DIRECTION_45 d_prev = ( i > 0 ? DIRECTION_45( aOrigin.CSegment( i-1 ) ) : DIRECTION_45() ); + int dirCount = 0; for( int j = 0; j < 2; j++ ) { paths[j] = d_start.BuildInitialTrace( p_start, aP, j ); - dirs[j] = DIRECTION_45( paths[j].CSegment( 0 ) ); + + if( paths[j].SegmentCount() < 1 ) + continue; + + assert( dirCount < sizeof( dirs ) / sizeof( dirs[0] ) ); + dirs[dirCount] = DIRECTION_45( paths[j].CSegment( 0 ) ); + ++dirCount; } - for( int j = 0; j < 2; j++ ) + for( int j = 0; j < dirCount; j++ ) { if( dirs[j] == d_start ) { @@ -381,7 +389,7 @@ SHAPE_LINE_CHAIN dragCornerInternal( const SHAPE_LINE_CHAIN& aOrigin, const VECT if( picked ) break; - for( int j = 0; j < 2; j++ ) + for( int j = 0; j < dirCount; j++ ) { if( dirs[j].IsObtuse( d_prev ) ) { diff --git a/pcbnew/router/pns_line_placer.cpp b/pcbnew/router/pns_line_placer.cpp index 705a65899c..a6282085b5 100644 --- a/pcbnew/router/pns_line_placer.cpp +++ b/pcbnew/router/pns_line_placer.cpp @@ -243,6 +243,9 @@ bool LINE_PLACER::reduceTail( const VECTOR2I& aEnd ) // the direction of the segment to be replaced SHAPE_LINE_CHAIN replacement = dir.BuildInitialTrace( s.A, aEnd ); + if( replacement.SegmentCount() < 1 ) + continue; + LINE tmp( m_tail, replacement ); if( m_currentNode->CheckColliding( &tmp, ITEM::ANY_T ) )