Patch 8.2.4229
Problem: Possible crash when invoking timer callback fails.
Solution: Initialize the typval. Give an error for an empty callback.
(closes #9636)
Files: src/time.c, src/testdir/test_vim9_builtin.vim
*** ../vim-8.2.4228/src/time.c 2022-01-24 11:23:59.859900461 +0000
--- src/time.c 2022-01-27 13:40:25.495833076 +0000
***************
*** 481,486 ****
--- 481,487 ----
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,859 ****
--- 855,867 ----
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)
*** ../vim-8.2.4228/src/testdir/test_vim9_builtin.vim 2022-01-26
18:25:47.689295506 +0000
--- src/testdir/test_vim9_builtin.vim 2022-01-27 13:43:05.461543608 +0000
***************
*** 4132,4137 ****
--- 4132,4139 ----
def Test_timer_start()
CheckDefAndScriptFailure(['timer_start("a", "1")'], ['E1013: Argument 1:
type mismatch, expected number but got string', 'E1210: Number required for
argument 1'])
CheckDefAndScriptFailure(['timer_start(1, "1", [1])'], ['E1013: Argument 3:
type mismatch, expected dict<any> but got list<number>', 'E1206: Dictionary
required for argument 3'])
+ CheckDefExecAndScriptFailure(['timer_start(100, 0)'], 'E921:')
+ CheckDefExecAndScriptFailure(['timer_start(100, "")'], 'E921:')
enddef
def Test_timer_stop()
*** ../vim-8.2.4228/src/version.c 2022-01-27 13:16:54.332078790 +0000
--- src/version.c 2022-01-27 13:34:24.796965904 +0000
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 4229,
/**/
--
An SQL statement walks into a bar. He approaches two tables
and says, "Mind if I join you?"
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/20220127135616.60B021C4EF6%40moolenaar.net.