Problem: Using a partial for timer_start() may cause a crash.
Solution: Set the copyID in timer objects. (Ozaki Kiichi)
abort = abort || set_ref_in_nb_channel(copyID);
#endif
+#ifdef FEAT_TIMERS
+ abort = abort || set_ref_in_timer(copyID);
+#endif
+
if (!abort)
{
/*
remove_timer(timer);
free_timer(timer);
}
+
+/*
+ * Mark references in partials of timers.
+ */
+ int
+set_ref_in_timer(int copyID)
+{
+ int abort = FALSE;
+ timer_T *timer;
+ typval_T tv;
+
+ for (timer = first_timer; timer != NULL; timer = timer->tr_next)
+ {
+ tv.v_type = VAR_PARTIAL;
+ tv.vval.v_partial = timer->tr_partial;
+ abort = abort || set_ref_in_item(&tv, copyID, NULL, NULL);
+ }
+ return abort;
+}
# endif
#if defined(FEAT_SYN_HL) && defined(FEAT_RELTIME) && defined(FEAT_FLOAT)
long check_due_timer(void);
timer_T *find_timer(int id);
void stop_timer(timer_T *timer);
+int set_ref_in_timer(int copyID);
void profile_divide(proftime_T *tm, int count, proftime_T *tm2);
void profile_add(proftime_T *tm, proftime_T *tm2);
void profile_self(proftime_T *self, proftime_T *total, proftime_T *children);
let s:val += 1
endfunc
+func MyHandlerWithLists(lists, timer)
+ let x = string(a:lists)
+endfunc
+
func Test_oneshot()
let s:val = 0
let timer = timer_start(50, 'MyHandler')
sleep 200m
call assert_equal(1, s:val)
endfunc
+
+func Test_retain_partial()
+ call timer_start(100, function('MyHandlerWithLists', [['a']]))
+ call test_garbagecollect_now()
+ sleep 200m
+endfunc
" vim: ts=2 sw=0 et
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1860,
/**/
1859,
/**/