From 3b3d3076f71b60f9c5c89f7f6879f0e67fc73f42 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 13 May 2026 08:56:18 +0800 Subject: [PATCH] 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 https://github.com/vim/vim/commit/38237411e4e202a96b0efe41567505331114bfa8 Co-authored-by: glepnir --- src/nvim/cmdexpand.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/nvim/cmdexpand.c b/src/nvim/cmdexpand.c index cf15e4dcef..339379d8fd 100644 --- a/src/nvim/cmdexpand.c +++ b/src/nvim/cmdexpand.c @@ -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; }