From a931ac436a14d32bd413e4b100581da023fe530e Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Wed, 21 Mar 2018 22:29:37 -0400 Subject: [PATCH] Add some safety checks to Excellon number format detection Fixes: lp:1754121 * https://bugs.launchpad.net/kicad/+bug/1754121 --- gerbview/excellon_read_drill_file.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/gerbview/excellon_read_drill_file.cpp b/gerbview/excellon_read_drill_file.cpp index c3f6230228..660c9ff19a 100644 --- a/gerbview/excellon_read_drill_file.cpp +++ b/gerbview/excellon_read_drill_file.cpp @@ -559,6 +559,13 @@ bool EXCELLON_IMAGE::Execute_Drill_Command( char*& text ) while( IsNumber( *read ) ) { + if( *read == '.' ) + { + integer = nbdigits; + read++; + continue; + } + if( ( *read >= '0' ) && ( *read <='9' ) ) nbdigits++; @@ -567,6 +574,10 @@ bool EXCELLON_IMAGE::Execute_Drill_Command( char*& text ) mantissa = nbdigits - integer; + // Enforce minimum mantissa of 3 for metric + if( m_GerbMetric && mantissa < 3 ) + mantissa = 3; + m_FmtScale.x = m_FmtScale.y = mantissa; m_FmtLen.x = m_FmtLen.y = integer + mantissa;