Mercurial > vim
changeset 8734:986f7c00d43d v7.4.1656
commit https://github.com/vim/vim/commit/92e35efaf6a3278e4729115648997f09cd4005f5
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Mar 26 18:20:41 2016 +0100
patch 7.4.1656
Problem: Crash when using partial with a timer.
Solution: Increment partial reference count. (Hirohito Higashi)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 26 Mar 2016 18:30:06 +0100 |
parents | 2eb831813772 |
children | d3f32626fabe |
files | src/eval.c src/testdir/test_timers.vim src/version.c |
diffstat | 3 files changed, 16 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/eval.c +++ b/src/eval.c @@ -20190,6 +20190,7 @@ get_callback(typval_T *arg, partial_T ** if (arg->v_type == VAR_PARTIAL && arg->vval.v_partial != NULL) { *pp = arg->vval.v_partial; + ++(*pp)->pt_refcount; return (*pp)->pt_name; } *pp = NULL;
--- a/src/testdir/test_timers.vim +++ b/src/testdir/test_timers.vim @@ -30,3 +30,16 @@ func Test_repeat_many() call assert_true(s:val > 1) call assert_true(s:val < 5) endfunc + +func Test_with_partial_callback() + let s:val = 0 + let s:meow = {} + function s:meow.bite(...) + let s:val += 1 + endfunction + + call timer_start(50, s:meow.bite) + sleep 200m + call assert_equal(1, s:val) +endfunc +" vim: ts=2 sw=0 et