mirror of
https://github.com/neovim/neovim.git
synced 2025-09-11 13:58:18 +00:00
vim-patch:7.4.2326
Problem: Illegal memory access when Visual selection starts in invalid
position. (Dominique Pelle)
Solution: Correct position when needed.
d5824ce1b5
This commit is contained in:
@@ -294,6 +294,24 @@ linenr_T get_cursor_rel_lnum(win_T *wp, linenr_T lnum)
|
|||||||
return (lnum < cursor) ? -retval : retval;
|
return (lnum < cursor) ? -retval : 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.
|
||||||
*/
|
*/
|
||||||
|
@@ -7831,6 +7831,7 @@ static void get_op_vcol(
|
|||||||
|
|
||||||
// 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -115,7 +115,7 @@ static int included_patches[] = {
|
|||||||
// 2329,
|
// 2329,
|
||||||
// 2328,
|
// 2328,
|
||||||
// 2327 NA
|
// 2327 NA
|
||||||
// 2326,
|
2326,
|
||||||
// 2325 NA
|
// 2325 NA
|
||||||
// 2324,
|
// 2324,
|
||||||
// 2323,
|
// 2323,
|
||||||
|
Reference in New Issue
Block a user