To: vim_dev@googlegroups.com Subject: Patch 8.2.3974 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3974 Problem: Vim9: LISTAPPEND instruction does not check for a locked list. Solution: Check whether the list is locked. (closes #9452) Files: src/vim9execute.c, src/testdir/test_vim9_builtin.vim *** ../vim-8.2.3973/src/vim9execute.c 2022-01-01 15:58:19.122486356 +0000 --- src/vim9execute.c 2022-01-01 18:01:41.085232230 +0000 *************** *** 3911,3922 **** list_T *l = tv1->vval.v_list; // add an item to a list if (l == NULL) { - SOURCING_LNUM = iptr->isn_lnum; emsg(_(e_cannot_add_to_null_list)); goto on_error; } if (list_append_tv(l, tv2) == FAIL) goto theend; clear_tv(tv2); --- 3911,3924 ---- list_T *l = tv1->vval.v_list; // add an item to a list + SOURCING_LNUM = iptr->isn_lnum; if (l == NULL) { emsg(_(e_cannot_add_to_null_list)); goto on_error; } + if (value_check_lock(l->lv_lock, NULL, FALSE)) + goto on_error; if (list_append_tv(l, tv2) == FAIL) goto theend; clear_tv(tv2); *** ../vim-8.2.3973/src/testdir/test_vim9_builtin.vim 2021-12-28 11:24:44.636994380 +0000 --- src/testdir/test_vim9_builtin.vim 2022-01-01 18:23:23.790531953 +0000 *************** *** 78,83 **** --- 78,94 ---- def Test_add() CheckDefAndScriptFailure(['add({}, 1)'], ['E1013: Argument 1: type mismatch, expected list but got dict', 'E1226: List or Blob required for argument 1']) CheckDefFailure(['add([1], "a")'], 'E1012: Type mismatch; expected number but got string') + + var lines =<< trim END + vim9script + g:thelist = [1] + lockvar g:thelist + def TryChange() + g:thelist->add(2) + enddef + TryChange() + END + CheckScriptFailure(lines, 'E741:') enddef def Test_add_blob() *** ../vim-8.2.3973/src/version.c 2022-01-01 16:31:44.015615365 +0000 --- src/version.c 2022-01-01 18:03:41.816976918 +0000 *************** *** 751,752 **** --- 751,754 ---- { /* Add new patch number below this line */ + /**/ + 3974, /**/ -- Rule #1: Don't give somebody a tool that he's going to hurt himself with. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///