From 21195a751d3d3af53482be66dc1f6baca8479ef1 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Wed, 8 Aug 2018 10:15:44 +0200 Subject: [PATCH] Eeschema: sch_legacy_plugin.cpp: fix incorrect parsing of pin position. The issue is in: wxPoint( parseInt( aReader, line, &line ), parseInt( aReader, line, &line ) ) that calls parseInt() twice, but parseInt changes parameters at each call. (Does not return the same value at each call). However, due to some side effect or compil optimization, the value returned is incorrect. It can be dependent of the compiler, and optimization level. This kind of code must be avoided. --- eeschema/sch_legacy_plugin.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/eeschema/sch_legacy_plugin.cpp b/eeschema/sch_legacy_plugin.cpp index 45cefe488c..7b5bda9fa2 100644 --- a/eeschema/sch_legacy_plugin.cpp +++ b/eeschema/sch_legacy_plugin.cpp @@ -3192,7 +3192,11 @@ LIB_PIN* SCH_LEGACY_PLUGIN_CACHE::loadPin( std::unique_ptr< LIB_PART >& aPart, parseUnquotedString( pin->m_name, aReader, line, &line ); parseUnquotedString( pin->m_number, aReader, line, &line ); - pin->m_position = wxPoint( parseInt( aReader, line, &line ), parseInt( aReader, line, &line ) ); + wxPoint pos; + pos.x = parseInt( aReader, line, &line ); + pos.y = parseInt( aReader, line, &line ); + pin->m_position = pos; + pin->m_length = parseInt( aReader, line, &line ); pin->m_orientation = parseChar( aReader, line, &line ); pin->m_numTextSize = parseInt( aReader, line, &line );