patch 9.1.1401: list not materialized in prop_list()
Commit:
https://github.com/vim/vim/commit/56b1207e66d8db82dabf3f36aadf24caea61aa71
Author: Christian Brabandt <[email protected]>
Date: Wed May 21 21:01:40 2025 +0200
patch 9.1.1401: list not materialized in prop_list()
Problem: list not materialized in prop_list()
(Nickwiz)
Solution: materialize list before accessing it
fixes: #17298
closes: #17349
Signed-off-by: Christian Brabandt <[email protected]>
diff --git a/src/testdir/test_textprop.vim b/src/testdir/test_textprop.vim
index d26efa948..bcf83cab8 100644
--- a/src/testdir/test_textprop.vim
+++ b/src/testdir/test_textprop.vim
@@ -4757,4 +4757,29 @@ func Test_textprop_with_wincolor()
call StopVimInTerminal(buf)
endfunc
+func Test_textprop_materialize_list()
+ let ids = range(3)
+ call assert_equal([], prop_list(1, #{ids: ids}))
+
+ let ids = range(3) + []
+ call assert_equal([], prop_list(1, #{ids: ids}))
+
+ let ids = range(3)
+ let ids[0] = ids[0]
+ call assert_equal([], prop_list(1, #{ids: ids}))
+
+ let ids = range(3)
+ call assert_equal([], prop_list(1, #{ids: ids}))
+
+ call assert_equal([], prop_list(1, #{ids: range(3) + [] }))
+
+ let ids = range(3)
+ call assert_equal([], prop_list(1, #{ids: ids}))
+
+ let ids = range(0, 3)
+ call assert_equal([], prop_list(1, #{ids: ids}))
+
+ call assert_equal([], prop_list(1, #{ids: 3->range()}))
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/textprop.c b/src/textprop.c
index d16f8ecef..a06605d3d 100644
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -1439,7 +1439,7 @@ get_prop_ids_from_list(list_T *l, int *num_ids)
{
int *prop_ids;
listitem_T *li;
- int i;
+ int i = 0;
int id;
int error;
@@ -1449,7 +1449,7 @@ get_prop_ids_from_list(list_T *l, int *num_ids)
if (prop_ids == NULL)
return NULL;
- i = 0;
+ CHECK_LIST_MATERIALIZE(l);
FOR_ALL_LIST_ITEMS(l, li)
{
error = FALSE;
diff --git a/src/version.c b/src/version.c
index a6c749dc0..252c1437b 100644
--- a/src/version.c
+++ b/src/version.c
@@ -709,6 +709,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1401,
/**/
1400,
/**/
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/vim_dev/E1uHou7-007DL1-CY%40256bit.org.