0
0
mirror of https://github.com/vim/vim.git synced 2025-09-07 22:03:36 -04:00

patch 8.2.3678: illegal memory access

Problem:    Illegal memory access.
Solution:   Ignore changed indent when computing byte offset.
This commit is contained in:
Bram Moolenaar 2021-11-25 20:40:11 +00:00
parent 4d07253a48
commit 85be8563fe
2 changed files with 6 additions and 2 deletions

View File

@ -2099,6 +2099,7 @@ do_put(
else
{
linenr_T new_lnum = new_cursor.lnum;
size_t len;
// Insert at least one line. When y_type is MCHAR, break the first
// line in two.
@ -2211,11 +2212,12 @@ 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
- mb_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;

View File

@ -757,6 +757,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
3678,
/**/
3677,
/**/