diff options
author | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2019-08-29 20:35:35 -0400 |
---|---|---|
committer | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2019-08-29 20:48:01 -0400 |
commit | f575b714499bf74ca99597fc5d115395e14dfcd1 (patch) | |
tree | a0ba9e4efef3d8d25468b64f6045bdaf70401e8a /src | |
parent | 9f81acc076779f891160423657cc35e6ac37c3e6 (diff) | |
download | rneovim-f575b714499bf74ca99597fc5d115395e14dfcd1.tar.gz rneovim-f575b714499bf74ca99597fc5d115395e14dfcd1.tar.bz2 rneovim-f575b714499bf74ca99597fc5d115395e14dfcd1.zip |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/eval.c | 12 |
1 files 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. */ |