patch 8.2.4229: possible crash when invoking timer callback fails
Problem: Possible crash when invoking timer callback fails.
Solution: Initialize the typval. Give an error for an empty callback.
(closes #9636)
diff --git a/src/time.c b/src/time.c
index 78e20eb..00275ef 100644
--- a/src/time.c
+++ b/src/time.c
@@ -481,6 +481,7 @@
argv[0].vval.v_number = (varnumber_T)timer->tr_id;
argv[1].v_type = VAR_UNKNOWN;
+ rettv.v_type = VAR_UNKNOWN;
call_callback(&timer->tr_callback, -1, &rettv, 1, argv);
clear_tv(&rettv);
}
@@ -854,6 +855,13 @@
callback = get_callback(&argvars[1]);
if (callback.cb_name == NULL)
return;
+ if (in_vim9script() && *callback.cb_name == NUL)
+ {
+ // empty callback is not useful for a timer
+ emsg(_(e_invalid_callback_argument));
+ free_callback(&callback);
+ return;
+ }
timer = create_timer(msec, repeat);
if (timer == NULL)