diff options
Diffstat (limited to 'src/client/cl_keys.c')
-rw-r--r-- | src/client/cl_keys.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/client/cl_keys.c b/src/client/cl_keys.c index 212ac8d5..c2cda2d6 100644 --- a/src/client/cl_keys.c +++ b/src/client/cl_keys.c @@ -532,12 +532,14 @@ void Field_CharEvent( field_t *edit, int ch ) { } if ( key_overstrikeMode ) { - if ( edit->cursor == MAX_EDIT_LINE - 1 ) + // - 2 to leave room for the leading slash and trailing \0 + if ( edit->cursor == MAX_EDIT_LINE - 2 ) return; edit->buffer[edit->cursor] = ch; edit->cursor++; } else { // insert mode - if ( len == MAX_EDIT_LINE - 1 ) { + // - 2 to leave room for the leading slash and trailing \0 + if ( len == MAX_EDIT_LINE - 2 ) { return; // all full } memmove( edit->buffer + edit->cursor + 1, @@ -581,8 +583,10 @@ void Console_Key (int key) { // enter finishes the line if ( key == K_ENTER || key == K_KP_ENTER ) { // if not in the game explicitly prepend a slash if needed - if ( cls.state != CA_ACTIVE && g_consoleField.buffer[0] != '\\' - && g_consoleField.buffer[0] != '/' ) { + if ( cls.state != CA_ACTIVE && + g_consoleField.buffer[0] && + g_consoleField.buffer[0] != '\\' && + g_consoleField.buffer[0] != '/' ) { char temp[MAX_EDIT_LINE-1]; Q_strncpyz( temp, g_consoleField.buffer, sizeof( temp ) ); |