diff options
author | Yegappan Lakshmanan <yegappan@yahoo.com> | 2022-09-02 17:12:07 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-09-02 17:12:07 +0100 |
commit | 956be4678fba2051a8d24c15cc5dc67fb89c515f (patch) | |
tree | 70e40e0f48e72309a78a81b4ddaad7f799565cb3 /src/testdir | |
parent | 35d21c6830fc2d68aca838424a0e786821c5891c (diff) |
patch 9.0.0361: removing a listener may result in a memory leakv9.0.0361
Problem: Removing a listener may result in a memory leak and remove
subsequent listerns.
Solution: Init the "prev" pointer only once. (Yegappan Lakshmanan,
closes #11039)
Diffstat (limited to 'src/testdir')
-rw-r--r-- | src/testdir/test_listener.vim | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/testdir/test_listener.vim b/src/testdir/test_listener.vim index 82b5ff03c9..413275d464 100644 --- a/src/testdir/test_listener.vim +++ b/src/testdir/test_listener.vim @@ -387,6 +387,37 @@ func Test_remove_listener_in_callback() unlet g:listener_called endfunc +" When multiple listeners are registered, remove one listener and verify the +" other listener is still called +func Test_remove_one_listener_in_callback() + new + let g:listener1_called = 0 + let g:listener2_called = 0 + let s:ID1 = listener_add('Listener1') + let s:ID2 = listener_add('Listener2') + func Listener1(...) + call listener_remove(s:ID1) + let g:listener1_called += 1 + endfunc + func Listener2(...) + let g:listener2_called += 1 + endfunc + call setline(1, ['foo']) + call feedkeys("~", 'xt') + call listener_flush() + call feedkeys("~", 'xt') + call listener_flush() + call assert_equal(1, g:listener1_called) + call assert_equal(2, g:listener2_called) + + call listener_remove(s:ID2) + bwipe! + delfunc Listener1 + delfunc Listener2 + unlet g:listener1_called + unlet g:listener2_called +endfunc + func Test_no_change_for_empty_undo() new let text = ['some word here', 'second line'] |