Prevent oob string access in SCH_REFERENCE::IsSplitNeeded

Fixes https://gitlab.com/kicad/code/kicad/-/issues/20948
This commit is contained in:
Marek Roszko 2025-05-24 00:01:16 -04:00
parent 2bdc7d4872
commit 10c7796336
2 changed files with 4 additions and 0 deletions

View File

@ -904,6 +904,9 @@ bool SCH_REFERENCE::IsSplitNeeded()
{ {
std::string refText = GetRefStr(); std::string refText = GetRefStr();
if( refText.empty() )
return false;
int ll = refText.length() - 1; int ll = refText.length() - 1;
return ( refText[ll] == '?' ) || isdigit( refText[ll] ); return ( refText[ll] == '?' ) || isdigit( refText[ll] );

View File

@ -2389,6 +2389,7 @@ int SCH_EDITOR_CONTROL::Annotate( const TOOL_EVENT& aEvent )
int SCH_EDITOR_CONTROL::IncrementAnnotations( const TOOL_EVENT& aEvent ) int SCH_EDITOR_CONTROL::IncrementAnnotations( const TOOL_EVENT& aEvent )
{ {
DIALOG_INCREMENT_ANNOTATIONS_BASE dlg( m_frame ); DIALOG_INCREMENT_ANNOTATIONS_BASE dlg( m_frame );
dlg.m_FirstRefDes->SetValidator( wxTextValidator( wxFILTER_EMPTY ) );
dlg.SetInitialFocus( dlg.m_FirstRefDes ); dlg.SetInitialFocus( dlg.m_FirstRefDes );