mirror of
https://github.com/neovim/neovim
synced 2025-07-15 16:51:49 +00:00
vim-patch:9.1.1510: Search completion may use invalid memory
Problem: Search completion may use invalid memory (after 9.1.1490).
Solution: Don't get two line pointers at the same time (zeertzjq).
closes: vim/vim#17661
5e34eec6f8
This commit is contained in:
@ -3875,15 +3875,13 @@ static int copy_substring_from_pos(pos_T *start, pos_T *end, char **match, pos_T
|
||||
|| (start->lnum == end->lnum && start->col >= end->col)) {
|
||||
return FAIL; // invalid range
|
||||
}
|
||||
// Get line pointers
|
||||
char *start_line = ml_get(start->lnum);
|
||||
char *end_line = ml_get(end->lnum);
|
||||
|
||||
// Use a growable string (ga)
|
||||
garray_T ga;
|
||||
ga_init(&ga, 1, 128);
|
||||
|
||||
// Append start line from start->col to end
|
||||
char *start_line = ml_get(start->lnum);
|
||||
char *start_ptr = start_line + start->col;
|
||||
bool is_single_line = start->lnum == end->lnum;
|
||||
|
||||
@ -3906,6 +3904,7 @@ static int copy_substring_from_pos(pos_T *start, pos_T *end, char **match, pos_T
|
||||
}
|
||||
|
||||
// Append partial end line (up to word end)
|
||||
char *end_line = ml_get(end->lnum);
|
||||
char *word_end = find_word_end(end_line + end->col);
|
||||
segment_len = (int)(word_end - end_line);
|
||||
ga_grow(&ga, segment_len);
|
||||
|
@ -4503,6 +4503,7 @@ func Test_search_wildmenu_screendump()
|
||||
CheckScreendump
|
||||
|
||||
let lines =<< trim [SCRIPT]
|
||||
call test_override('alloc_lines', 1)
|
||||
set wildmenu wildcharm=<f5>
|
||||
call setline(1, ['the', 'these', 'the', 'foobar', 'thethe', 'thethere'])
|
||||
[SCRIPT]
|
||||
|
Reference in New Issue
Block a user