Skip to content

Commit

Permalink
Fix a few chat buffer issues (#54)
Browse files Browse the repository at this point in the history
* fix buffer underflow writing to chat
* fix another chat buffer write
  • Loading branch information
NotAFile authored and xtreme8000 committed Jun 28, 2018
1 parent a1457d8 commit 63e0b5b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/hud.c
Expand Up @@ -1314,7 +1314,10 @@ static void hud_ingame_keyboard(int key, int action, int mods) {
chat_input_mode = CHAT_NO_INPUT;
}
if(key==WINDOW_KEY_BACKSPACE) {
chat[0][0][strlen(chat[0][0])-1] = 0;
size_t text_len = strlen(chat[0][0]);
if (text_len > 0){
chat[0][0][text_len-1] = 0;
}
}
}
}
Expand Down Expand Up @@ -1611,7 +1614,10 @@ static void hud_serverlist_keyboard(int key, int action, int mods) {
serverlist_scroll -= 20.0F;
}
if(key==WINDOW_KEY_BACKSPACE) {
chat[0][0][strlen(chat[0][0])-1] = 0;
size_t text_len = strlen(chat[0][0]);
if (text_len > 0){
chat[0][0][text_len-1] = 0;
}
}
if(key==WINDOW_KEY_ENTER && strlen(chat[0][0])>0) {
server_c(chat[0][0]);
Expand Down

0 comments on commit 63e0b5b

Please sign in to comment.