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)
c507a2d164
This commit is contained in:
Jan Edmund Lazo
2019-08-29 20:35:35 -04:00
parent 9f81acc076
commit f575b71449

View File

@@ -6437,6 +6437,10 @@ call_func(
typval_T argv[MAX_FUNC_ARGS + 1]; // used when "partial" is not NULL typval_T argv[MAX_FUNC_ARGS + 1]; // used when "partial" is not NULL
int argv_clear = 0; 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 // Make a copy of the name, if it comes from a funcref variable it could
// be changed or deleted in the called function. // be changed or deleted in the called function.
name = vim_strnsave(funcname, len); name = vim_strnsave(funcname, len);
@@ -6465,13 +6469,7 @@ call_func(
} }
} }
if (error == ERROR_NONE && evaluate) {
// 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) {
char_u *rfname = fname; char_u *rfname = fname;
/* Ignore "g:" before a function name. */ /* Ignore "g:" before a function name. */