From 8ac9abd4fad5837c2cc7a858827efb2e53b852be Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 17 Aug 2023 16:58:05 +0800 Subject: vim-patch:9.0.1416: crash when collection is modified when using filter() Problem: Crash when collection is modified when using filter(). Solution: Lock the list/dict/blob. (Ernie Rael, closes vim/vim#12183) https://github.com/vim/vim/commit/e6d40dcdc7227594935d2db01eca29f0e575dcee Co-authored-by: Ernie Rael --- test/old/testdir/test_filter_map.vim | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'test') diff --git a/test/old/testdir/test_filter_map.vim b/test/old/testdir/test_filter_map.vim index 3040b7b0d0..7658797759 100644 --- a/test/old/testdir/test_filter_map.vim +++ b/test/old/testdir/test_filter_map.vim @@ -109,6 +109,21 @@ func Test_map_and_modify() let d = #{a: 1, b: 2, c: 3} call assert_fails('call map(d, "remove(d, v:key)[0]")', 'E741:') call assert_fails('echo map(d, {k,v -> remove(d, k)})', 'E741:') + + let b = 0z1234 + call assert_fails('call filter(b, "remove(b, 0)")', 'E741:') +endfunc + +func Test_filter_and_modify() + let l = [0] + " cannot change the list halfway a map() + call assert_fails('call filter(l, "remove(l, 0)")', 'E741:') + + let d = #{a: 0, b: 0, c: 0} + call assert_fails('call filter(d, "remove(d, v:key)")', 'E741:') + + let b = 0z1234 + call assert_fails('call filter(b, "remove(b, 0)")', 'E741:') endfunc func Test_mapnew_dict() -- cgit