From d4fddf1929a48118f0b41425513d646ab3f365f7 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Tue, 22 Aug 2017 13:29:46 +0200 Subject: [PATCH] Fix eeschema crash when saving LIB_BEZIER objects --- common/bezier_curves.cpp | 1 + eeschema/lib_bezier.cpp | 8 +++----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/common/bezier_curves.cpp b/common/bezier_curves.cpp index bbf94acb0b..e1196242f7 100644 --- a/common/bezier_curves.cpp +++ b/common/bezier_curves.cpp @@ -47,6 +47,7 @@ static inline double sqrt_len( int dx, int dy ) void BEZIER_POLY::GetPoly( std::vector& aOutput ) { + wxCHECK( !m_ctrlPts.empty(), /* void */ ); m_output = &aOutput; m_output->clear(); m_output->push_back( wxPoint( m_ctrlPts.front() ) ); diff --git a/eeschema/lib_bezier.cpp b/eeschema/lib_bezier.cpp index 8a7aa95768..a225a5efa1 100644 --- a/eeschema/lib_bezier.cpp +++ b/eeschema/lib_bezier.cpp @@ -42,7 +42,7 @@ #include -LIB_BEZIER::LIB_BEZIER( LIB_PART* aParent ) : +LIB_BEZIER::LIB_BEZIER( LIB_PART* aParent ) : LIB_ITEM( LIB_BEZIER_T, aParent ) { m_Fill = NO_FILL; @@ -58,10 +58,8 @@ bool LIB_BEZIER::Save( OUTPUTFORMATTER& aFormatter ) aFormatter.Print( 0, "B %d %d %d %d", ccount, m_Unit, m_Convert, m_Width ); - for( unsigned i = 0; i < GetCornerCount(); i++ ) - { - aFormatter.Print( 0, " %d %d", m_BezierPoints[i].x, m_BezierPoints[i].y ); - } + for( const auto& pt : m_BezierPoints ) + aFormatter.Print( 0, " %d %d", pt.x, pt.y ); aFormatter.Print( 0, " %c\n", fill_tab[m_Fill] );