Mercurial > vim
diff src/testdir/test_listener.vim @ 17151:ebe9aab81898 v8.1.1575
patch 8.1.1575: callbacks may be garbage collected
commit https://github.com/vim/vim/commit/75a1a9415b9c207de5a29b25c0d1949c6c9c5c61
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Jun 20 03:45:36 2019 +0200
patch 8.1.1575: callbacks may be garbage collected
Problem: Callbacks may be garbage collected.
Solution: Set reference in callbacks. (Ozaki Kiichi, closes https://github.com/vim/vim/issues/4564)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 20 Jun 2019 04:00:07 +0200 |
parents | 5493e31010e1 |
children | 31f31e938961 |
line wrap: on
line diff
--- a/src/testdir/test_listener.vim +++ b/src/testdir/test_listener.vim @@ -225,3 +225,20 @@ func Test_listening_other_buf() exe "buf " .. bufnr bwipe! endfunc + +func Test_listener_garbage_collect() + func MyListener(x, bufnr, start, end, added, changes) + " NOP + endfunc + + new + let id = listener_add(function('MyListener', [{}]), bufnr('')) + call test_garbagecollect_now() + " must not crach caused by invalid memory access + normal ia + call assert_true(v:true) + + call listener_remove(id) + delfunc MyListener + bwipe! +endfunc