aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/testdir
diff options
context:
space:
mode:
authorSean Dewar <seandewar@users.noreply.github.com>2021-12-06 22:51:08 +0000
committerzeertzjq <zeertzjq@outlook.com>2022-01-31 17:38:57 +0800
commit8d99f53f3dc0815d5515551473367d06669836e0 (patch)
tree6520d8f1c1350c7d2c09eef6a008b83085c4ec6f /src/nvim/testdir
parent44a5875b24f033c472af50aa4eec4468c554b7c9 (diff)
downloadrneovim-8d99f53f3dc0815d5515551473367d06669836e0.tar.gz
rneovim-8d99f53f3dc0815d5515551473367d06669836e0.tar.bz2
rneovim-8d99f53f3dc0815d5515551473367d06669836e0.zip
vim-patch:8.2.1083: crash when using reduce() on a NULL list
Problem: Crash when using reduce() on a NULL list. Solution: Only access the list when not NULL. https://github.com/vim/vim/commit/fda20c4cc59008264676a6deb6a3095ed0c248e0 CHECK_LIST_MATERIALIZE hasn't been ported yet, but presumably if it is ported it'll use tv_list_first to check for range_list_item, which already checks for NULL, so this should need no extra changes and can be a full port. We didn't actually crash here due to the use of Nvim's tv_list functions checking for NULL, but apply these changes to match Vim better anyway.
Diffstat (limited to 'src/nvim/testdir')
-rw-r--r--src/nvim/testdir/test_listdict.vim3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/nvim/testdir/test_listdict.vim b/src/nvim/testdir/test_listdict.vim
index fdf9123d82..114cca7ec0 100644
--- a/src/nvim/testdir/test_listdict.vim
+++ b/src/nvim/testdir/test_listdict.vim
@@ -658,6 +658,9 @@ func Test_reduce()
call assert_fails("call reduce(g:lut, { acc, val -> EvilRemove() }, 1)", 'E742:')
unlet g:lut
delfunc EvilRemove
+
+ call assert_equal(42, reduce(v:_null_list, function('add'), 42))
+ call assert_equal(42, reduce(v:_null_blob, function('add'), 42))
endfunc
" splitting a string to a List