* (bug 3454) Fix crash in autocompletion due to incorrect strncpy buffer size

This commit is contained in:
Tim Angus 2007-12-03 00:07:56 +00:00
parent dfc97a1dfa
commit 6113cf7a68
1 changed files with 6 additions and 3 deletions

View File

@ -3292,6 +3292,8 @@ static void Field_CompleteCommand( char *cmd,
}
else
{
int completionOffset;
if( completionString[0] == '\\' || completionString[0] == '/' )
completionString++;
@ -3310,9 +3312,10 @@ static void Field_CompleteCommand( char *cmd,
if( matchCount == 0 )
return; // no matches
Q_strncpyz( &completionField->buffer[ strlen( completionField->buffer ) -
strlen( completionString ) ], shortestMatch,
sizeof( completionField->buffer ) );
completionOffset = strlen( completionField->buffer ) - strlen( completionString );
Q_strncpyz( &completionField->buffer[ completionOffset ], shortestMatch,
sizeof( completionField->buffer ) - completionOffset );
completionField->cursor = strlen( completionField->buffer );