From 7779a01d48626dc9e65976fb0c9099c0a12f9192 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Thu, 29 Jun 2023 09:48:04 -0700 Subject: [PATCH] SIM_VALUE stores significants in 64-bit stol isn't neccesarily 64-bit though, so we use stoll and catch the overflow if we have bad input data Fixes KICAD-2EF --- eeschema/sim/sim_value.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/eeschema/sim/sim_value.cpp b/eeschema/sim/sim_value.cpp index 118f40ec7b..7dc2350360 100644 --- a/eeschema/sim/sim_value.cpp +++ b/eeschema/sim/sim_value.cpp @@ -164,10 +164,17 @@ static inline void handleNodeForParse( tao::pegtl::parse_tree::node& aNode, for( const auto& subnode : aNode.children ) { - if( subnode->is_type() ) - aParseResult.intPart = std::stol( subnode->string() ); - else if( subnode->is_type() ) - aParseResult.fracPart = std::stol( subnode->string() ); + try + { + if( subnode->is_type() ) + aParseResult.intPart = std::stoll( subnode->string() ); + else if( subnode->is_type() ) + aParseResult.fracPart = std::stoll( subnode->string() ); + } + catch( const std::exception& ) + { + aParseResult.isOk = false; + } } } else if( aNode.is_type() )