From 4b49f312a05214d5d1974f7ac2702ffb407fc558 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 15 Apr 2023 13:17:32 +0800 Subject: vim-patch:8.2.0633: crash when using null partial in filter() Problem: Crash when using null partial in filter(). Solution: Fix crash. Add more tests. (Yegappan Lakshmanan, closes vim/vim#5976) https://github.com/vim/vim/commit/9d8d0b5c644ea53364d04403740b3f23e57c1497 Co-authored-by: Bram Moolenaar --- test/old/testdir/test_partial.vim | 45 ++++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 13 deletions(-) (limited to 'test/old/testdir/test_partial.vim') diff --git a/test/old/testdir/test_partial.vim b/test/old/testdir/test_partial.vim index 3020668f1b..f813539d42 100644 --- a/test/old/testdir/test_partial.vim +++ b/test/old/testdir/test_partial.vim @@ -63,16 +63,18 @@ endfunc func Test_partial_dict() let dict = {'name': 'hello'} let Cb = function('MyDictFunc', ["foo", "bar"], dict) + call test_garbagecollect_now() call assert_equal("hello/foo/bar", Cb()) call assert_fails('Cb("xxx")', 'E492:') + let Cb = function('MyDictFunc', ["foo"], dict) + call assert_equal("hello/foo/xxx", Cb("xxx")) + call assert_fails('Cb()', 'E492:') + let Cb = function('MyDictFunc', [], dict) call assert_equal("hello/ttt/xxx", Cb("ttt", "xxx")) call assert_fails('Cb("yyy")', 'E492:') - let Cb = function('MyDictFunc', ["foo"], dict) - call assert_equal("hello/foo/xxx", Cb("xxx")) - call assert_fails('Cb()', 'E492:') let Cb = function('MyDictFunc', dict) call assert_equal("hello/xxx/yyy", Cb("xxx", "yyy")) call assert_fails('Cb("fff")', 'E492:') @@ -238,17 +240,22 @@ endfunc func Ignored(job1, job2, status) endfunc -" func Test_cycle_partial_job() -" let job = job_start('echo') -" call job_setoptions(job, {'exit_cb': function('Ignored', [job])}) -" unlet job -" endfunc +func Test_cycle_partial_job() + if has('job') + let job = job_start('echo') + call job_setoptions(job, {'exit_cb': function('Ignored', [job])}) + unlet job + endif +endfunc -" func Test_ref_job_partial_dict() -" let g:ref_job = job_start('echo') -" let d = {'a': 'b'} -" call job_setoptions(g:ref_job, {'exit_cb': function('string', [], d)}) -" endfunc +func Test_ref_job_partial_dict() + if has('job') + let g:ref_job = job_start('echo') + let d = {'a': 'b'} + call job_setoptions(g:ref_job, {'exit_cb': function('string', [], d)}) + call test_garbagecollect_now() + endif +endfunc func Test_auto_partial_rebind() let dict1 = {'name': 'dict1'} @@ -356,6 +363,18 @@ func Test_compare_partials() call assert_true(F1 isnot# F2) " Different functions call assert_true(F1 isnot# F1d1) " Partial /= non-partial call assert_true(d1.f1 isnot# d1.f1) " handle_subscript creates new partial each time + + " compare two null partials + " Nvim doesn't have null partials + " let N1 = test_null_partial() + let N1 = function('min') + let N2 = N1 + call assert_true(N1 is N2) + call assert_true(N1 == N2) + + " compare a partial and a null partial + call assert_false(N1 == F1) + call assert_false(F1 is N1) endfunc " vim: shiftwidth=2 sts=2 expandtab -- cgit From 85741677c86f7686e3597a310f8059608e7816fb Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 15 Apr 2023 13:31:30 +0800 Subject: vim-patch:8.2.0634: crash with null partial and blob Problem: Crash with null partial and blob. Solution: Check for NULL pointer. Add more tests. (Yegappan Lakshmanan, closes vim/vim#5984) https://github.com/vim/vim/commit/92b83ccfda7a1d654ccaaf161a9c8a8e01fbcf76 Co-authored-by: Bram Moolenaar --- test/old/testdir/test_partial.vim | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'test/old/testdir/test_partial.vim') diff --git a/test/old/testdir/test_partial.vim b/test/old/testdir/test_partial.vim index f813539d42..302bc22d93 100644 --- a/test/old/testdir/test_partial.vim +++ b/test/old/testdir/test_partial.vim @@ -194,6 +194,10 @@ func Test_partial_string() call assert_equal("function('MyFunc', {'one': 1})", string(F)) let F = function('MyFunc', ['foo'], d) call assert_equal("function('MyFunc', ['foo'], {'one': 1})", string(F)) + " Nvim doesn't have null functions + " call assert_equal("function('')", string(test_null_function())) + " Nvim doesn't have null partials + " call assert_equal("function('')", string(test_null_partial())) endfunc func Test_func_unref() -- cgit