Patch 8.2.1083
Problem: Crash when using reduce() on a NULL list.
Solution: Only access the list when not NULL.
Files: src/list.c, src/testdir/test_listdict.vim
*** ../vim-8.2.1082/src/list.c 2020-06-27 21:17:55.359214424 +0200
--- src/list.c 2020-06-29 20:07:07.347220096 +0200
***************
*** 2475,2484 ****
list_T *l = argvars[0].vval.v_list;
listitem_T *li = NULL;
int r;
- int prev_locked = l->lv_lock;
int called_emsg_start = called_emsg;
! CHECK_LIST_MATERIALIZE(l);
if (argvars[2].v_type == VAR_UNKNOWN)
{
if (l == NULL || l->lv_first == NULL)
--- 2475,2484 ----
list_T *l = argvars[0].vval.v_list;
listitem_T *li = NULL;
int r;
int called_emsg_start = called_emsg;
! if (l != NULL)
! CHECK_LIST_MATERIALIZE(l);
if (argvars[2].v_type == VAR_UNKNOWN)
{
if (l == NULL || l->lv_first == NULL)
***************
*** 2495,2514 ****
if (l != NULL)
li = l->lv_first;
}
-
- l->lv_lock = VAR_FIXED; // disallow the list changing here
copy_tv(&initial, rettv);
! for ( ; li != NULL; li = li->li_next)
{
! argv[0] = *rettv;
! argv[1] = li->li_tv;
! rettv->v_type = VAR_UNKNOWN;
! r = call_func(func_name, -1, rettv, 2, argv, &funcexe);
! clear_tv(&argv[0]);
! if (r == FAIL || called_emsg != called_emsg_start)
! break;
}
- l->lv_lock = prev_locked;
}
else
{
--- 2495,2519 ----
if (l != NULL)
li = l->lv_first;
}
copy_tv(&initial, rettv);
!
! if (l != NULL)
{
! int prev_locked = l->lv_lock;
!
! l->lv_lock = VAR_FIXED; // disallow the list changing here
! for ( ; li != NULL; li = li->li_next)
! {
! argv[0] = *rettv;
! argv[1] = li->li_tv;
! rettv->v_type = VAR_UNKNOWN;
! r = call_func(func_name, -1, rettv, 2, argv, &funcexe);
! clear_tv(&argv[0]);
! if (r == FAIL || called_emsg != called_emsg_start)
! break;
! }
! l->lv_lock = prev_locked;
}
}
else
{
*** ../vim-8.2.1082/src/testdir/test_listdict.vim 2020-06-24
22:07:41.816626147 +0200
--- src/testdir/test_listdict.vim 2020-06-29 20:08:50.598906721 +0200
***************
*** 718,723 ****
--- 718,726 ----
call assert_fails("call reduce(g:lut, { acc, val -> EvilRemove() }, 1)",
'E742:')
unlet g:lut
delfunc EvilRemove
+
+ call assert_equal(42, reduce(test_null_list(), function('add'), 42))
+ call assert_equal(42, reduce(test_null_blob(), function('add'), 42))
endfunc
" splitting a string to a List using split()
*** ../vim-8.2.1082/src/version.c 2020-06-29 19:55:54.885328478 +0200
--- src/version.c 2020-06-29 20:02:33.171734058 +0200
***************
*** 756,757 ****
--- 756,759 ----
{ /* Add new patch number below this line */
+ /**/
+ 1083,
/**/
--
An SQL statement walks into a bar. He approaches two tables
and says, "Mind if I join you?"
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ 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/202006291810.05TIA3CF673199%40masaka.moolenaar.net.