Patch 8.2.1051

8 views
Skip to first unread message

Bram Moolenaar

unread,
Jun 24, 2020, 4:08:28 PM6/24/20
to vim...@googlegroups.com

Patch 8.2.1051
Problem: Crash when changing a list while using reduce() on it.
Solution: Lock the list. (closes #6330)
Files: src/list.c, src/testdir/test_listdict.vim


*** ../vim-8.2.1050/src/list.c 2020-06-24 18:37:28.359249374 +0200
--- src/list.c 2020-06-24 22:04:10.061236468 +0200
***************
*** 2461,2466 ****
--- 2461,2468 ----
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)
***************
*** 2480,2485 ****
--- 2482,2488 ----
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)
{
***************
*** 2488,2496 ****
rettv->v_type = VAR_UNKNOWN;
r = call_func(func_name, -1, rettv, 2, argv, &funcexe);
clear_tv(&argv[0]);
! if (r == FAIL)
! return;
}
}
else
{
--- 2491,2500 ----
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.1050/src/testdir/test_listdict.vim 2020-06-01 18:39:14.040317510 +0200
--- src/testdir/test_listdict.vim 2020-06-24 22:07:26.932669222 +0200
***************
*** 709,714 ****
--- 709,723 ----
call assert_fails("call reduce({}, { acc, val -> acc + val }, 1)", 'E897:')
call assert_fails("call reduce(0, { acc, val -> acc + val }, 1)", 'E897:')
call assert_fails("call reduce('', { acc, val -> acc + val }, 1)", 'E897:')
+
+ let g:lut = [1, 2, 3, 4]
+ func EvilRemove()
+ call remove(g:lut, 1)
+ return 1
+ endfunc
+ call assert_fails("call reduce(g:lut, { acc, val -> EvilRemove() }, 1)", 'E742:')
+ unlet g:lut
+ delfunc EvilRemove
endfunc

" splitting a string to a List using split()
*** ../vim-8.2.1050/src/version.c 2020-06-24 21:00:20.627874946 +0200
--- src/version.c 2020-06-24 22:06:44.612791574 +0200
***************
*** 756,757 ****
--- 756,759 ----
{ /* Add new patch number below this line */
+ /**/
+ 1051,
/**/

--
BEDEVERE: How do you know so much about swallows?
ARTHUR: Well you have to know these things when you're a king, you know.
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

/// Bram Moolenaar -- Br...@Moolenaar.net -- 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 ///
Reply all
Reply to author
Forward
0 new messages