mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 8.0.1433: illegal memory access after undo
Problem: Illegal memory access after undo. (Dominique Pelle) Solution: Avoid the column becomes negative. (Christian Brabandt, closes #2533)
This commit is contained in:
@@ -1784,6 +1784,7 @@ dbcs_ptr2char(char_u *p)
|
|||||||
* Convert a UTF-8 byte sequence to a wide character.
|
* Convert a UTF-8 byte sequence to a wide character.
|
||||||
* If the sequence is illegal or truncated by a NUL the first byte is
|
* If the sequence is illegal or truncated by a NUL the first byte is
|
||||||
* returned.
|
* returned.
|
||||||
|
* For an overlong sequence this may return zero.
|
||||||
* Does not include composing characters, of course.
|
* Does not include composing characters, of course.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
@@ -4112,7 +4113,10 @@ mb_adjustpos(buf_T *buf, pos_T *lp)
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
p = ml_get_buf(buf, lp->lnum, FALSE);
|
p = ml_get_buf(buf, lp->lnum, FALSE);
|
||||||
lp->col -= (*mb_head_off)(p, p + lp->col);
|
if (*p == NUL || (int)STRLEN(p) < lp->col)
|
||||||
|
lp->col = 0;
|
||||||
|
else
|
||||||
|
lp->col -= (*mb_head_off)(p, p + lp->col);
|
||||||
#ifdef FEAT_VIRTUALEDIT
|
#ifdef FEAT_VIRTUALEDIT
|
||||||
/* Reset "coladd" when the cursor would be on the right half of a
|
/* Reset "coladd" when the cursor would be on the right half of a
|
||||||
* double-wide character. */
|
* double-wide character. */
|
||||||
|
@@ -350,3 +350,12 @@ func Test_cmd_in_reg_undo()
|
|||||||
only!
|
only!
|
||||||
let @a=''
|
let @a=''
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" This used to cause an illegal memory access
|
||||||
|
func Test_undo_append()
|
||||||
|
new
|
||||||
|
call feedkeys("axx\<Esc>v", 'xt')
|
||||||
|
undo
|
||||||
|
norm o
|
||||||
|
quit
|
||||||
|
endfunc
|
||||||
|
@@ -771,6 +771,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1433,
|
||||||
/**/
|
/**/
|
||||||
1432,
|
1432,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user