diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2017-01-20 13:49:38 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-20 13:49:38 +0100 |
commit | 030349d85239421fb44f00e01b833d2a12cfd40a (patch) | |
tree | 70c4e53eb6c42043b20ae7c79106de577498b521 | |
parent | 4b2759b6dadced6648a53f3ba9f3bd039ecbbd8f (diff) | |
download | rneovim-030349d85239421fb44f00e01b833d2a12cfd40a.tar.gz rneovim-030349d85239421fb44f00e01b833d2a12cfd40a.tar.bz2 rneovim-030349d85239421fb44f00e01b833d2a12cfd40a.zip |
input_enqueue(): Fix length calculation. (#5981)
Ref: https://github.com/neovim/neovim/issues/5885#issuecomment-273614373
-rw-r--r-- | src/nvim/os/input.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/nvim/os/input.c b/src/nvim/os/input.c index b60a7eed36..f264a26939 100644 --- a/src/nvim/os/input.c +++ b/src/nvim/os/input.c @@ -170,12 +170,13 @@ bool os_isatty(int fd) size_t input_enqueue(String keys) { - char *ptr = keys.data, *end = ptr + keys.size; + char *ptr = keys.data; + char *end = ptr + keys.size; while (rbuffer_space(input_buffer) >= 6 && ptr < end) { uint8_t buf[6] = { 0 }; - unsigned int new_size = trans_special((const uint8_t **)&ptr, keys.size, - buf, true); + unsigned int new_size + = trans_special((const uint8_t **)&ptr, (size_t)(end - ptr), buf, true); if (new_size) { new_size = handle_mouse_event(&ptr, buf, new_size); @@ -185,8 +186,7 @@ size_t input_enqueue(String keys) if (*ptr == '<') { char *old_ptr = ptr; - // Invalid or incomplete key sequence, skip until the next '>' or until - // *end + // Invalid or incomplete key sequence, skip until the next '>' or *end. do { ptr++; } while (ptr < end && *ptr != '>'); |