mirror of
https://github.com/neovim/neovim.git
synced 2025-09-11 22:08:18 +00:00
vim-patch:8.2.4969: changing text in Visual mode may cause invalid memory access
Problem: Changing text in Visual mode may cause invalid memory access.
Solution: Check the Visual position after making a change.
7ce5b2b590
This commit is contained in:
@@ -399,6 +399,24 @@ void check_cursor(void)
|
||||
check_cursor_col();
|
||||
}
|
||||
|
||||
/// Check if VIsual position is valid, correct it if not.
|
||||
/// Can be called when in Visual mode and a change has been made.
|
||||
void check_visual_pos(void)
|
||||
{
|
||||
if (VIsual.lnum > curbuf->b_ml.ml_line_count) {
|
||||
VIsual.lnum = curbuf->b_ml.ml_line_count;
|
||||
VIsual.col = 0;
|
||||
VIsual.coladd = 0;
|
||||
} else {
|
||||
int len = (int)STRLEN(ml_get(VIsual.lnum));
|
||||
|
||||
if (VIsual.col > len) {
|
||||
VIsual.col = len;
|
||||
VIsual.coladd = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Make sure curwin->w_cursor is not on the NUL at the end of the line.
|
||||
/// Allow it when in Visual mode and 'selection' is not "old".
|
||||
void adjust_cursor_col(void)
|
||||
|
Reference in New Issue
Block a user