0
0
mirror of https://github.com/vim/vim.git synced 2025-10-22 08:34:29 -04:00

patch 9.0.1416: crash when collection is modified when using filter()

Problem:    Crash when collection is modified when using filter().
Solution:   Lock the list/dict/blob. (Ernie Rael, closes #12183)
This commit is contained in:
Ernie Rael
2023-03-19 21:23:38 +00:00
committed by Bram Moolenaar
parent 7c4516fe93
commit e6d40dcdc7
6 changed files with 36 additions and 14 deletions

View File

@@ -1305,7 +1305,7 @@ dict_extend_func(
action = (char_u *)"force";
if (type != NULL && check_typval_arg_type(type, &argvars[1],
func_name, 2) == FAIL)
func_name, 2) == FAIL)
return;
dict_extend(d1, d2, action, func_name);
@@ -1333,7 +1333,6 @@ dict_filter_map(
typval_T *expr,
typval_T *rettv)
{
int prev_lock;
dict_T *d_ret = NULL;
hashtab_T *ht;
hashitem_T *hi;
@@ -1353,8 +1352,6 @@ dict_filter_map(
&& value_check_lock(d->dv_lock, arg_errmsg, TRUE)))
return;
prev_lock = d->dv_lock;
if (filtermap == FILTERMAP_MAPNEW)
{
if (rettv_dict_alloc(rettv) == FAIL)
@@ -1365,7 +1362,8 @@ dict_filter_map(
// Create one funccal_T for all eval_expr_typval() calls.
fc = eval_expr_get_funccal(expr, &newtv);
if (filtermap != FILTERMAP_FILTER && d->dv_lock == 0)
int prev_lock = d->dv_lock;
if (d->dv_lock == 0)
d->dv_lock = VAR_LOCKED;
ht = &d->dv_hashtab;
hash_lock(ht);