Commit: patch 9.1.1880: Allocation error with complete_info()

1 view
Skip to first unread message

Christian Brabandt

unread,
Oct 27, 2025, 1:45:20 PMOct 27
to vim...@googlegroups.com
patch 9.1.1880: Allocation error with complete_info()

Commit: https://github.com/vim/vim/commit/7d3b647f886d3bf9f9764ef644dfedfc5117f902
Author: kuuote <znmx...@gmail.com>
Date: Mon Oct 27 17:26:29 2025 +0000

patch 9.1.1880: Allocation error with complete_info()

Problem: Allocation error with complete_info()
(after v9.1.1876)
Solution: Make sure length is positive (kuuote)

closes: #18640

Signed-off-by: kuuote <znmx...@gmail.com>
Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/src/insexpand.c b/src/insexpand.c
index 321700414..f3cbeb253 100644
--- a/src/insexpand.c
+++ b/src/insexpand.c
@@ -4235,7 +4235,7 @@ get_complete_info(list_T *what_list, dict_T *retdict)
int len = compl_ins_end_col - curwin->w_cursor.col;

ret = dict_add_string_len(retdict, "preinserted_text",
- (len > 0) ? line + curwin->w_cursor.col : (char_u *)"", len);
+ (len > 0) ? line + curwin->w_cursor.col : (char_u *)"", (len > 0) ? len : 0);
}

if (ret == OK && (what_flag & (CI_WHAT_ITEMS | CI_WHAT_SELECTED
diff --git a/src/testdir/test_ins_complete.vim b/src/testdir/test_ins_complete.vim
index 02a193cad..84d1236e3 100644
--- a/src/testdir/test_ins_complete.vim
+++ b/src/testdir/test_ins_complete.vim
@@ -571,6 +571,10 @@ func Test_completefunc_info()
new
set completeopt=menuone
set completefunc=CompleteTest
+ " Can be called outside of ins-completion
+ call feedkeys("i\<C-X>\<C-U>\<C-Y>\<C-R>\<C-R>=string(complete_info())\<CR>\<ESC>", "tx")
+ call assert_equal("matched{'preinserted_text': '', 'pum_visible': 0, 'mode': '', 'selected': -1, 'items': []}", getline(1))
+ %d
call feedkeys("i\<C-X>\<C-U>\<C-R>\<C-R>=string(complete_info())\<CR>\<ESC>", "tx")
call assert_equal("matched{'preinserted_text': '', 'pum_visible': 1, 'mode': 'function', 'selected': 0, 'items': [{'word': 'matched', 'menu': '', 'user_data': '', 'info': '', 'kind': '', 'abbr': ''}]}", getline(1))
%d
diff --git a/src/version.c b/src/version.c
index 3f33a0e6f..54f6d841d 100644
--- a/src/version.c
+++ b/src/version.c
@@ -729,6 +729,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1880,
/**/
1879,
/**/
Reply all
Reply to author
Forward
0 new messages