From 424cdf6699efea7b7a21769f4cb0422e9aa088db Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 26 Dec 2022 14:30:57 +0000 Subject: [PATCH] Overflow safety. Sentry issue https://sentry.io/organizations/kicad/issues/3419671947/events/11212297e66c47c7af7144b5f075e88c/ --- eeschema/sim/sim_model.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/eeschema/sim/sim_model.cpp b/eeschema/sim/sim_model.cpp index f66d0f4fc9..3f110057ef 100644 --- a/eeschema/sim/sim_model.cpp +++ b/eeschema/sim/sim_model.cpp @@ -666,7 +666,8 @@ std::vector> SIM_MODEL::GetPins() c void SIM_MODEL::SetPinSymbolPinNumber( int aPinIndex, const std::string& aSymbolPinNumber ) { - m_pins.at( aPinIndex ).symbolPinNumber = aSymbolPinNumber; + if( aPinIndex >= 0 && aPinIndex < (int) m_pins.size() ) + m_pins.at( aPinIndex ).symbolPinNumber = aSymbolPinNumber; } @@ -686,7 +687,7 @@ void SIM_MODEL::SetPinSymbolPinNumber( const std::string& aPinName, // for legacy files which didn't use pin names. int aPinIndex = (int) strtol( aPinName.c_str(), nullptr, 10 ); - if( aPinIndex < 1 ) + if( aPinIndex < 1 || aPinIndex > (int) m_pins.size() ) { THROW_IO_ERROR( wxString::Format( _( "Could not find a pin named '%s' in simulation " "model of type '%s'" ),