vim-patch:8.2.3756: might crash when callback is not valid

Problem:    might crash when callback is not valid.
Solution:   Check for valid callback. (Yegappan Lakshmanan, closes vim/vim#9293)

4dc24eb5ad

Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
This commit is contained in:
zeertzjq
2022-11-07 11:04:33 +08:00
parent 42e44d6d33
commit d7bd7f13a8
7 changed files with 42 additions and 10 deletions

View File

@@ -1394,7 +1394,7 @@ func_call_skip_call:
}
/// call the 'callback' function and return the result as a number.
/// Returns -1 when calling the function fails. Uses argv[0] to argv[argc - 1]
/// Returns -2 when calling the function fails. Uses argv[0] to argv[argc - 1]
/// for the function arguments. argv[argc] should have type VAR_UNKNOWN.
///
/// @param argcount number of "argvars"
@@ -1403,7 +1403,7 @@ varnumber_T callback_call_retnr(Callback *callback, int argcount, typval_T *argv
{
typval_T rettv;
if (!callback_call(callback, argcount, argvars, &rettv)) {
return -1;
return -2;
}
varnumber_T retval = tv_get_number_chk(&rettv, NULL);