1
0
mirror of https://github.com/Tha14/toxic.git synced 2025-06-29 00:36:45 +02:00

fix undefined behaviour with string literals

This commit is contained in:
Jfreegman
2014-07-16 12:47:14 -04:00
parent b23ae5a4c3
commit ce4f293574
6 changed files with 56 additions and 35 deletions

View File

@ -185,7 +185,8 @@ static void input_history(ToxWindow *self, wint_t key, int mx_x)
ChatContext *ctx = self->chatwin;
fetch_hist_item(ctx, key);
ctx->start = mx_x * (ctx->len / mx_x);
int wlen = wcswidth(ctx->line, sizeof(ctx->line));
ctx->start = wlen < mx_x ? 0 : wlen - mx_x + 1;
}
/* Handles non-printable input keys that behave the same for all types of chat windows.