diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-01-29 06:05:39 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2022-01-29 06:05:39 +0800 |
commit | 3adc3fc540ada79860d90b48b66a1e967421aabf (patch) | |
tree | 2a1d5a23892ff89b55625e95de0a700c6ab63bbe | |
parent | 6f04d3f3ef5eb45c224dabc64373783de9d3f721 (diff) | |
download | rneovim-3adc3fc540ada79860d90b48b66a1e967421aabf.tar.gz rneovim-3adc3fc540ada79860d90b48b66a1e967421aabf.tar.bz2 rneovim-3adc3fc540ada79860d90b48b66a1e967421aabf.zip |
vim-patch:8.2.3678: illegal memory access
Problem: Illegal memory access.
Solution: Ignore changed indent when computing byte offset.
https://github.com/vim/vim/commit/85be8563fe5aff686e9e30d6afff401ccd976f2a
-rw-r--r-- | src/nvim/ops.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/nvim/ops.c b/src/nvim/ops.c index c29668f541..3a2851f84f 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -3473,6 +3473,7 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags) } } else { linenr_T new_lnum = new_cursor.lnum; + size_t len; // Insert at least one line. When y_type is kMTCharWise, break the first // line in two. @@ -3592,10 +3593,11 @@ error: // Put the '] mark on the first byte of the last inserted character. // Correct the length for change in indent. curbuf->b_op_end.lnum = new_lnum; - col = (colnr_T)STRLEN(y_array[y_size - 1]) - lendiff; + len = STRLEN(y_array[y_size - 1]); + col = (colnr_T)len - lendiff; if (col > 1) { curbuf->b_op_end.col = col - 1 - utf_head_off(y_array[y_size - 1], - y_array[y_size - 1] + col - 1); + y_array[y_size - 1] + len - 1); } else { curbuf->b_op_end.col = 0; } |