mirror of
https://github.com/vim/vim.git
synced 2025-09-26 04:04:07 -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:
22
src/misc2.c
22
src/misc2.c
@@ -504,6 +504,28 @@ get_cursor_rel_lnum(
|
||||
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.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user