Fix relative return with nullptr condition
Previous fix for CVE munged return conditions for gerber files in some cases. This restores the proper order where a nullptr will return 0,0 in the relative case and the current coordinate in others Also fixes incorrect scale factor for inches/mils conversion to mm
This commit is contained in:
parent
7b84e0a7d9
commit
c79916b359
|
@ -62,7 +62,7 @@ int scaletoIU( double aCoord, bool isMetric )
|
|||
if( isMetric ) // gerber are units in mm
|
||||
ret = KiROUND( aCoord * GERB_IU_PER_MM );
|
||||
else // gerber are units in inches
|
||||
ret = KiROUND( aCoord * GERB_IU_PER_MM * 0.0254 );
|
||||
ret = KiROUND( aCoord * GERB_IU_PER_MM * 25.4 );
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -78,7 +78,8 @@ VECTOR2I GERBER_FILE_IMAGE::ReadXYCoord( char*& aText, bool aExcellonMode )
|
|||
// Reserve the anticipated length plus an optional sign and decimal
|
||||
line.reserve( std::max( m_FmtLen.x, m_FmtLen.y ) + 3 );
|
||||
|
||||
if( m_Relative )
|
||||
// Set up return value for case where aText == nullptr
|
||||
if( !m_Relative )
|
||||
pos = m_CurrentPos;
|
||||
|
||||
if( aText == nullptr )
|
||||
|
@ -142,11 +143,11 @@ VECTOR2I GERBER_FILE_IMAGE::ReadXYCoord( char*& aText, bool aExcellonMode )
|
|||
|
||||
if( type_coord == 'X' )
|
||||
{
|
||||
pos.x += current_coord;
|
||||
pos.x = current_coord;
|
||||
}
|
||||
else if( type_coord == 'Y' )
|
||||
{
|
||||
pos.y += current_coord;
|
||||
pos.y = current_coord;
|
||||
}
|
||||
else if( type_coord == 'A' )
|
||||
{
|
||||
|
@ -155,6 +156,9 @@ VECTOR2I GERBER_FILE_IMAGE::ReadXYCoord( char*& aText, bool aExcellonMode )
|
|||
}
|
||||
}
|
||||
|
||||
if( m_Relative )
|
||||
pos += m_CurrentPos;
|
||||
|
||||
m_CurrentPos = pos;
|
||||
return pos;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue