summaryrefslogtreecommitdiff
path: root/src/list.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-06-24 22:07:46 +0200
committerBram Moolenaar <Bram@vim.org>2020-06-24 22:07:46 +0200
commitca275a05d8b79f6a9101604fdede2373d0dea44e (patch)
tree257b8511185a6e3ff164361b0f7a97ba6c6f7431 /src/list.c
parent65a8ed37f7bc61fbe5c612a7b0eb0dfc16ad3e11 (diff)
downloadvim-git-ca275a05d8b79f6a9101604fdede2373d0dea44e.tar.gz
patch 8.2.1051: crash when changing a list while using reduce() on itv8.2.1051
Problem: Crash when changing a list while using reduce() on it. Solution: Lock the list. (closes #6330)
Diffstat (limited to 'src/list.c')
-rw-r--r--src/list.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/list.c b/src/list.c
index c624003a2..cf0c99f13 100644
--- a/src/list.c
+++ b/src/list.c
@@ -2461,6 +2461,8 @@ f_reduce(typval_T *argvars, typval_T *rettv)
list_T *l = argvars[0].vval.v_list;
listitem_T *li = NULL;
int r;
+ int prev_locked = l->lv_lock;
+ int called_emsg_start = called_emsg;
CHECK_LIST_MATERIALIZE(l);
if (argvars[2].v_type == VAR_UNKNOWN)
@@ -2480,6 +2482,7 @@ f_reduce(typval_T *argvars, typval_T *rettv)
li = l->lv_first;
}
+ l->lv_lock = VAR_FIXED; // disallow the list changing here
copy_tv(&initial, rettv);
for ( ; li != NULL; li = li->li_next)
{
@@ -2488,9 +2491,10 @@ f_reduce(typval_T *argvars, typval_T *rettv)
rettv->v_type = VAR_UNKNOWN;
r = call_func(func_name, -1, rettv, 2, argv, &funcexe);
clear_tv(&argv[0]);
- if (r == FAIL)
- return;
+ if (r == FAIL || called_emsg != called_emsg_start)
+ break;
}
+ l->lv_lock = prev_locked;
}
else
{