diff --git a/src/chat.c b/src/chat.c index 75d5cda..c5f1f68 100644 --- a/src/chat.c +++ b/src/chat.c @@ -378,7 +378,7 @@ static void chat_onKey(ToxWindow *self, Tox *m, wint_t key) #else if (isprint(key)) { #endif - if (ctx->pos <= MAX_STR_SIZE) { + if (ctx->pos < (MAX_STR_SIZE-1)) { mvwaddstr(self->window, y, x, wc_to_char(key)); ctx->line[ctx->pos++] = key; ctx->line[ctx->pos] = L'\0'; diff --git a/src/prompt.c b/src/prompt.c index 7b859da..4a772dd 100644 --- a/src/prompt.c +++ b/src/prompt.c @@ -136,7 +136,7 @@ static void prompt_onKey(ToxWindow *self, Tox *m, wint_t key) /* Add printable characters to line */ else if (isprint(key)) { - if (prompt_buf_pos <= MAX_STR_SIZE) { + if (prompt_buf_pos < (MAX_STR_SIZE-1)) { mvwaddch(self->window, y, x, key); prompt_buf[prompt_buf_pos++] = key; prompt_buf[prompt_buf_pos] = '\0';