mirror of
https://github.com/vim/vim
synced 2025-07-16 01:01:58 +00:00
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: #17661 Signed-off-by: zeertzjq <zeertzjq@outlook.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
96b3ef2389
commit
5e34eec6f8
@ -4638,14 +4638,11 @@ copy_substring_from_pos(pos_T *start, pos_T *end, char_u **match,
|
|||||||
|| (start->lnum == end->lnum && start->col >= end->col))
|
|| (start->lnum == end->lnum && start->col >= end->col))
|
||||||
return FAIL; // invalid range
|
return FAIL; // invalid range
|
||||||
|
|
||||||
// Get line pointers
|
|
||||||
start_line = ml_get(start->lnum);
|
|
||||||
end_line = ml_get(end->lnum);
|
|
||||||
|
|
||||||
// Use a growable string (ga)
|
// Use a growable string (ga)
|
||||||
ga_init2(&ga, 1, 128);
|
ga_init2(&ga, 1, 128);
|
||||||
|
|
||||||
// Append start line from start->col to end
|
// Append start line from start->col to end
|
||||||
|
start_line = ml_get(start->lnum);
|
||||||
char_u *start_ptr = start_line + start->col;
|
char_u *start_ptr = start_line + start->col;
|
||||||
int is_single_line = start->lnum == end->lnum;
|
int is_single_line = start->lnum == end->lnum;
|
||||||
|
|
||||||
@ -4672,6 +4669,7 @@ copy_substring_from_pos(pos_T *start, pos_T *end, char_u **match,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Append partial end line (up to word end)
|
// Append partial end line (up to word end)
|
||||||
|
end_line = ml_get(end->lnum);
|
||||||
word_end = find_word_end(end_line + end->col);
|
word_end = find_word_end(end_line + end->col);
|
||||||
segment_len = (int)(word_end - end_line);
|
segment_len = (int)(word_end - end_line);
|
||||||
if (ga_grow(&ga, segment_len) != OK)
|
if (ga_grow(&ga, segment_len) != OK)
|
||||||
|
@ -4504,6 +4504,7 @@ func Test_search_wildmenu_screendump()
|
|||||||
CheckScreendump
|
CheckScreendump
|
||||||
|
|
||||||
let lines =<< trim [SCRIPT]
|
let lines =<< trim [SCRIPT]
|
||||||
|
call test_override('alloc_lines', 1)
|
||||||
set wildmenu wildcharm=<f5>
|
set wildmenu wildcharm=<f5>
|
||||||
call setline(1, ['the', 'these', 'the', 'foobar', 'thethe', 'thethere'])
|
call setline(1, ['the', 'these', 'the', 'foobar', 'thethe', 'thethere'])
|
||||||
[SCRIPT]
|
[SCRIPT]
|
||||||
|
@ -719,6 +719,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 */
|
||||||
|
/**/
|
||||||
|
1510,
|
||||||
/**/
|
/**/
|
||||||
1509,
|
1509,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user