vim-patch:9.2.0476: pattern completion leaks memory on alloc failures (#39767)

Problem:  copy_substring_from_pos() leaked on ga_grow() failures,
          expand_pattern_in_buf() leaked "match" on ga_grow() failure,
          fuzzy_match_str_with_pos() ignored ga_grow() failures
Solution: Route failures through cleanup paths, check ga_grow before
          writing to ga_data (glepnir)

closes: vim/vim#20203

38237411e4

Co-authored-by: glepnir <glephunter@gmail.com>
This commit is contained in:
zeertzjq
2026-05-13 08:56:18 +08:00
committed by GitHub
parent 228e6ca32a
commit 3b3d3076f7

View File

@@ -4363,8 +4363,8 @@ static int expand_pattern_in_buf(char *pat, Direction dir, char ***matches, int
}
// Extract the matching text prepended to completed word
if (!copy_substring_from_pos(&cur_match_pos, &end_match_pos, &full_match,
&word_end_pos)) {
if (copy_substring_from_pos(&cur_match_pos, &end_match_pos, &full_match,
&word_end_pos) == FAIL) {
break;
}