From f575b714499bf74ca99597fc5d115395e14dfcd1 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Thu, 29 Aug 2019 20:35:35 -0400 Subject: vim-patch:8.1.1938: may crash when out of memory Problem: May crash when out of memory. Solution: Initialize v_type to VAR_UNKNOWN. (Dominique Pelle, closes vim/vim#4871) https://github.com/vim/vim/commit/c507a2d164cfa3dcf31a7ba9dad6663a17243bb4 --- src/nvim/eval.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/nvim/eval.c b/src/nvim/eval.c index d883b53ed2..9f1f564a9b 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -6437,6 +6437,10 @@ call_func( typval_T argv[MAX_FUNC_ARGS + 1]; // used when "partial" is not NULL int argv_clear = 0; + // Initialize rettv so that it is safe for caller to invoke clear_tv(rettv) + // even when call_func() returns FAIL. + rettv->v_type = VAR_UNKNOWN; + // Make a copy of the name, if it comes from a funcref variable it could // be changed or deleted in the called function. name = vim_strnsave(funcname, len); @@ -6465,13 +6469,7 @@ call_func( } } - - // Execute the function if executing and no errors were detected. - if (!evaluate) { - // Not evaluating, which means the return value is unknown. This - // matters for giving error messages. - rettv->v_type = VAR_UNKNOWN; - } else if (error == ERROR_NONE) { + if (error == ERROR_NONE && evaluate) { char_u *rfname = fname; /* Ignore "g:" before a function name. */ -- cgit