Patch 8.2.3182
Problem: Vim9: crash when using removing items from a constant list.
(Yegappan Lakshmanan)
Solution: When a list was allocated with items copy them.
Files: src/list.c, src/testdir/test_vim9_builtin.vim
*** ../vim-8.2.3181/src/list.c 2021-07-09 19:17:52.238004722 +0200
--- src/list.c 2021-07-18 22:20:30.058085310 +0200
***************
*** 1566,1577 ****
vimlist_remove(l, item, item2);
if (rettv_list_alloc(rettv) == OK)
{
! l = rettv->vval.v_list;
! l->lv_first = item;
! l->lv_u.mat.lv_last = item2;
! item->li_prev = NULL;
! item2->li_next = NULL;
! l->lv_len = cnt;
}
}
}
--- 1566,1597 ----
vimlist_remove(l, item, item2);
if (rettv_list_alloc(rettv) == OK)
{
! list_T *rl = rettv->vval.v_list;
!
! if (l->lv_with_items > 0)
! {
! // need to copy the list items and move the value
! while (item != NULL)
! {
! li = listitem_alloc();
! if (li == NULL)
! return;
! li->li_tv = item->li_tv;
! init_tv(&item->li_tv);
! list_append(rl, li);
! if (item == item2)
! break;
! item = item->li_next;
! }
! }
! else
! {
! rl->lv_first = item;
! rl->lv_u.mat.lv_last = item2;
! item->li_prev = NULL;
! item2->li_next = NULL;
! rl->lv_len = cnt;
! }
}
}
}
*** ../vim-8.2.3181/src/testdir/test_vim9_builtin.vim 2021-07-18
21:44:30.856765322 +0200
--- src/testdir/test_vim9_builtin.vim 2021-07-18 22:23:24.153853482 +0200
***************
*** 2083,2088 ****
--- 2083,2094 ----
CheckDefFailure(['remote_startserver({})'], 'E1013: Argument 1: type
mismatch, expected string but got dict<unknown>')
enddef
+ def Test_remove_const_list()
+ var l: list<number> = [1, 2, 3, 4]
+ assert_equal([1, 2], remove(l, 0, 1))
+ assert_equal([3, 4], l)
+ enddef
+
def Test_remove_return_type()
var l = remove({one: [1, 2], two: [3, 4]}, 'one')
var res = 0
*** ../vim-8.2.3181/src/version.c 2021-07-18 21:44:30.856765322 +0200
--- src/version.c 2021-07-18 22:16:27.466402543 +0200
***************
*** 757,758 ****
--- 757,760 ----
{ /* Add new patch number below this line */
+ /**/
+ 3182,
/**/
--
hundred-and-one symptoms of being an internet addict:
177. You log off of your system because it's time to go to work.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
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 on the web visit
https://groups.google.com/d/msgid/vim_dev/202107182025.16IKPudM2837690%40masaka.moolenaar.net.