summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-08-29 21:32:55 +0200
committerBram Moolenaar <Bram@vim.org>2019-08-29 21:32:55 +0200
commitc507a2d164cfa3dcf31a7ba9dad6663a17243bb4 (patch)
treebcae5ea688703043ec12cc7a6c2e36eec1f627ae
parent4fb15c647658b15230c61857c644230a03881904 (diff)
downloadvim-git-c507a2d164cfa3dcf31a7ba9dad6663a17243bb4.tar.gz
patch 8.1.1938: may crash when out of memoryv8.1.1938
Problem: May crash when out of memory. Solution: Initialize v_type to VAR_UNKNOWN. (Dominique Pelle, closes #4871)
-rw-r--r--src/userfunc.c15
-rw-r--r--src/version.c2
2 files changed, 7 insertions, 10 deletions
diff --git a/src/userfunc.c b/src/userfunc.c
index 7366fc5cd..3f9171d2e 100644
--- a/src/userfunc.c
+++ b/src/userfunc.c
@@ -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;
diff --git a/src/version.c b/src/version.c
index c6bf6c5c6..96e0b40bb 100644
--- a/src/version.c
+++ b/src/version.c
@@ -762,6 +762,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1938,
+/**/
1937,
/**/
1936,