0
0
mirror of https://github.com/vim/vim.git synced 2025-09-26 04:04:07 -04:00

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 #4871)
This commit is contained in:
Bram Moolenaar
2019-08-29 21:32:55 +02:00
parent 4fb15c6476
commit c507a2d164
2 changed files with 7 additions and 10 deletions

View File

@@ -1501,6 +1501,10 @@ call_func(
int argv_base = 0;
partial_T *partial = funcexe->partial;
// 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 = len > 0 ? vim_strnsave(funcname, len) : vim_strsave(funcname);
@@ -1530,16 +1534,7 @@ call_func(
}
}
/*
* Execute the function if executing and no errors were detected.
*/
if (!funcexe->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 && funcexe->evaluate)
{
char_u *rfname = fname;