0
0
mirror of https://github.com/vim/vim.git synced 2025-09-27 04:14:06 -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

@@ -592,9 +592,10 @@ blob_filter_map(
blob_T *blob_arg,
filtermap_T filtermap,
typval_T *expr,
char_u *arg_errmsg,
typval_T *rettv)
{
blob_T *b;
blob_T *b = blob_arg;
int i;
typval_T tv;
varnumber_T val;
@@ -609,7 +610,8 @@ blob_filter_map(
rettv->v_type = VAR_BLOB;
rettv->vval.v_blob = NULL;
}
if ((b = blob_arg) == NULL)
if (b == NULL || (filtermap == FILTERMAP_FILTER
&& value_check_lock(b->bv_lock, arg_errmsg, TRUE)))
return;
b_ret = b;
@@ -623,6 +625,10 @@ blob_filter_map(
// set_vim_var_nr() doesn't set the type
set_vim_var_type(VV_KEY, VAR_NUMBER);
int prev_lock = b->bv_lock;
if (b->bv_lock == 0)
b->bv_lock = VAR_LOCKED;
// Create one funccal_T for all eval_expr_typval() calls.
fc = eval_expr_get_funccal(expr, &newtv);
@@ -658,6 +664,7 @@ blob_filter_map(
++idx;
}
b->bv_lock = prev_lock;
if (fc != NULL)
remove_funccal();
}