Don't run off the end of a string.

Fixes https://gitlab.com/kicad/code/kicad/issues/7461
This commit is contained in:
Jeff Young 2021-02-08 11:37:49 +00:00
parent a475f45753
commit 02aca4a7d7
1 changed files with 10 additions and 2 deletions

View File

@ -169,8 +169,16 @@ wxString KIwxExpandEnvVars( const wxString& str, const PROJECT* aProject )
size_t m = n + 1; size_t m = n + 1;
wxUniChar str_m = str[m]; wxUniChar str_m = str[m];
while( m < strlen && ( wxIsalnum( str_m ) || str_m == wxT( '_' ) || str_m == wxT( ':' ) ) ) while( wxIsalnum( str_m ) || str_m == wxT( '_' ) || str_m == wxT( ':' ) )
str_m = str[++m]; {
if( ++m == strlen )
{
str_m = 0;
break;
}
str_m = str[m];
}
wxString strVarName( str.c_str() + n + 1, m - n - 1 ); wxString strVarName( str.c_str() + n + 1, m - n - 1 );