Mercurial > vim
diff src/userfunc.c @ 26452:65b4109a4297 v8.2.3756
patch 8.2.3756: might crash when callback is not valid
Commit: https://github.com/vim/vim/commit/4dc24eb5adbcc76838fae1e900936dd230209d96
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Tue Dec 7 12:23:57 2021 +0000
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 https://github.com/vim/vim/issues/9293)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 07 Dec 2021 13:30:05 +0100 |
parents | 568f93dcdc62 |
children | 7821550ba3a8 |
line wrap: on
line diff
--- a/src/userfunc.c +++ b/src/userfunc.c @@ -3146,6 +3146,7 @@ get_callback_depth(void) /* * Invoke call_func() with a callback. + * Returns FAIL if the callback could not be called. */ int call_callback( @@ -3159,6 +3160,8 @@ call_callback( funcexe_T funcexe; int ret; + if (callback->cb_name == NULL || *callback->cb_name == NUL) + return FAIL; CLEAR_FIELD(funcexe); funcexe.evaluate = TRUE; funcexe.partial = callback->cb_partial; @@ -3170,7 +3173,7 @@ call_callback( /* * 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. */ varnumber_T @@ -3184,7 +3187,7 @@ call_callback_retnr( varnumber_T retval; if (call_callback(callback, 0, &rettv, argcount, argvars) == FAIL) - return -1; + return -2; retval = tv_get_number_chk(&rettv, NULL); clear_tv(&rettv);