Add more bounds checking in KIwxExpandEnvVars
Fixes https://gitlab.com/kicad/code/kicad/-/issues/7461
This commit is contained in:
parent
6c29f54988
commit
35438d3533
|
@ -167,6 +167,10 @@ wxString KIwxExpandEnvVars( const wxString& str, const PROJECT* aProject )
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t m = n + 1;
|
size_t m = n + 1;
|
||||||
|
|
||||||
|
if( m >= strlen )
|
||||||
|
break;
|
||||||
|
|
||||||
wxUniChar str_m = str[m];
|
wxUniChar str_m = str[m];
|
||||||
|
|
||||||
while( wxIsalnum( str_m ) || str_m == wxT( '_' ) || str_m == wxT( ':' ) )
|
while( wxIsalnum( str_m ) || str_m == wxT( '_' ) || str_m == wxT( ':' ) )
|
||||||
|
@ -243,7 +247,7 @@ wxString KIwxExpandEnvVars( const wxString& str, const PROJECT* aProject )
|
||||||
|
|
||||||
case wxT( '\\' ):
|
case wxT( '\\' ):
|
||||||
// backslash can be used to suppress special meaning of % and $
|
// backslash can be used to suppress special meaning of % and $
|
||||||
if( n != strlen - 1 && (str[n + 1] == wxT( '%' ) || str[n + 1] == wxT( '$' )) )
|
if( n < strlen - 1 && (str[n + 1] == wxT( '%' ) || str[n + 1] == wxT( '$' )) )
|
||||||
{
|
{
|
||||||
str_n = str[++n];
|
str_n = str[++n];
|
||||||
strResult += str_n;
|
strResult += str_n;
|
||||||
|
|
Loading…
Reference in New Issue