mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 7.4.2326
Problem: Illegal memory access when Visual selection starts in invalid position. (Dominique Pelle) Solution: Correct position when needed.
This commit is contained in:
parent
30180b8dad
commit
d5824ce1b5
22
src/misc2.c
22
src/misc2.c
@ -504,6 +504,28 @@ get_cursor_rel_lnum(
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Make sure "pos.lnum" and "pos.col" are valid in "buf".
|
||||||
|
* This allows for the col to be on the NUL byte.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
check_pos(buf_T *buf, pos_T *pos)
|
||||||
|
{
|
||||||
|
char_u *line;
|
||||||
|
colnr_T len;
|
||||||
|
|
||||||
|
if (pos->lnum > buf->b_ml.ml_line_count)
|
||||||
|
pos->lnum = buf->b_ml.ml_line_count;
|
||||||
|
|
||||||
|
if (pos->col > 0)
|
||||||
|
{
|
||||||
|
line = ml_get_buf(buf, pos->lnum, FALSE);
|
||||||
|
len = (colnr_T)STRLEN(line);
|
||||||
|
if (pos->col > len)
|
||||||
|
pos->col = len;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Make sure curwin->w_cursor.lnum is valid.
|
* Make sure curwin->w_cursor.lnum is valid.
|
||||||
*/
|
*/
|
||||||
|
@ -9451,7 +9451,10 @@ get_op_vcol(
|
|||||||
#ifdef FEAT_MBYTE
|
#ifdef FEAT_MBYTE
|
||||||
/* prevent from moving onto a trail byte */
|
/* prevent from moving onto a trail byte */
|
||||||
if (has_mbyte)
|
if (has_mbyte)
|
||||||
|
{
|
||||||
|
check_pos(curwin->w_buffer, &oap->end);
|
||||||
mb_adjustpos(curwin->w_buffer, &oap->end);
|
mb_adjustpos(curwin->w_buffer, &oap->end);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
getvvcol(curwin, &(oap->start), &oap->start_vcol, NULL, &oap->end_vcol);
|
getvvcol(curwin, &(oap->start), &oap->start_vcol, NULL, &oap->end_vcol);
|
||||||
|
@ -12,6 +12,7 @@ int dec_cursor(void);
|
|||||||
int dec(pos_T *lp);
|
int dec(pos_T *lp);
|
||||||
int decl(pos_T *lp);
|
int decl(pos_T *lp);
|
||||||
linenr_T get_cursor_rel_lnum(win_T *wp, linenr_T lnum);
|
linenr_T get_cursor_rel_lnum(win_T *wp, linenr_T lnum);
|
||||||
|
void check_pos(buf_T *buf, pos_T *pos);
|
||||||
void check_cursor_lnum(void);
|
void check_cursor_lnum(void);
|
||||||
void check_cursor_col(void);
|
void check_cursor_col(void);
|
||||||
void check_cursor_col_win(win_T *win);
|
void check_cursor_col_win(win_T *win);
|
||||||
|
@ -763,6 +763,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 */
|
||||||
|
/**/
|
||||||
|
2326,
|
||||||
/**/
|
/**/
|
||||||
2325,
|
2325,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user