neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit ce05990823034b18f6284a28df2a79b4be96acd8
parent c2e0fd1c35c22b4c53f903fb46fe9005926b1e16
Author: Jan Edmund Lazo <jan.lazo@mail.utoronto.ca>
Date:   Sun, 14 Dec 2025 01:24:20 -0500

vim-patch:8.2.4528: crash when using null_function for a partial

Problem:    Crash when using null_function for a partial.
Solution:   Don't call fname_trans_sid() with NULL. (closes vim/vim#9908)

https://github.com/vim/vim/commit/673bcb10ebe87ccf6954dd342d0143eb88cdfbcb

Co-authored-by: Bram Moolenaar <Bram@vim.org>

Diffstat:
Msrc/nvim/eval/userfunc.c | 18+++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c @@ -3778,8 +3778,7 @@ int func_has_abort(void *cookie) /// Changes "rettv" in-place. void make_partial(dict_T *const selfdict, typval_T *const rettv) { - char *tofree = NULL; - ufunc_T *fp; + ufunc_T *fp = NULL; char fname_buf[FLEN_FIXED + 1]; int error; @@ -3789,14 +3788,19 @@ void make_partial(dict_T *const selfdict, typval_T *const rettv) char *fname = rettv->v_type == VAR_FUNC || rettv->v_type == VAR_STRING ? rettv->vval.v_string : rettv->vval.v_partial->pt_name; - // Translate "s:func" to the stored function name. - fname = fname_trans_sid(fname, fname_buf, &tofree, &error); - fp = find_func(fname); - xfree(tofree); + if (fname != NULL) { + char *tofree = NULL; + + // Translate "s:func" to the stored function name. + fname = fname_trans_sid(fname, fname_buf, &tofree, &error); + fp = find_func(fname); + xfree(tofree); + } } // Turn "dict.Func" into a partial for "Func" with "dict". - if (fp != NULL && (fp->uf_flags & FC_DICT)) { + if ((fp != NULL && (fp->uf_flags & FC_DICT)) + || (rettv->v_type == VAR_FUNC && rettv->vval.v_string == NULL)) { partial_T *pt = (partial_T *)xcalloc(1, sizeof(partial_T)); pt->pt_refcount = 1; pt->pt_dict = selfdict;