diff options
author | watiko <service@mail.watiko.net> | 2016-02-16 23:05:47 +0900 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2016-02-22 01:12:47 -0500 |
commit | 9403ce82bce1a2dcda4b01b10b2c01ee42bb4034 (patch) | |
tree | e1cfc6ea2c9b1dac4b2671905e8bd7b0323ab082 /src/nvim/os/input.c | |
parent | bfe9ebcbe1a4aff708f0fce1ee0e0589be32e8d8 (diff) | |
download | rneovim-9403ce82bce1a2dcda4b01b10b2c01ee42bb4034.tar.gz rneovim-9403ce82bce1a2dcda4b01b10b2c01ee42bb4034.tar.bz2 rneovim-9403ce82bce1a2dcda4b01b10b2c01ee42bb4034.zip |
vim-patch:7.4.936 #4271
Problem: Crash when dragging with the mouse.
Solution: Add safety check for NULL pointer. Check mouse position for valid
value. (Hirohito Higashi)
https://github.com/vim/vim/commit/294a7e55b01149154807a23323038784549b8946
---
see: "Crash while mouse-selecting in two-buffer mode"
https://github.com/vim/vim/issues/486
Fix #3704
Diffstat (limited to 'src/nvim/os/input.c')
-rw-r--r-- | src/nvim/os/input.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/nvim/os/input.c b/src/nvim/os/input.c index e632544856..f317fd6b5a 100644 --- a/src/nvim/os/input.c +++ b/src/nvim/os/input.c @@ -250,6 +250,14 @@ static unsigned int handle_mouse_event(char **ptr, uint8_t *buf, int col, row, advance; if (sscanf(*ptr, "<%d,%d>%n", &col, &row, &advance) != EOF && advance) { if (col >= 0 && row >= 0) { + // Make sure the mouse position is valid. Some terminals may + // return weird values. + if (col >= Columns) { + col = (int)Columns - 1; + } + if (row >= Rows) { + row = (int)Rows - 1; + } mouse_row = row; mouse_col = col; } |