Mercurial > vim
diff src/dict.c @ 32170:5848a0867b26 v9.0.1416
patch 9.0.1416: crash when collection is modified when using filter()
Commit: https://github.com/vim/vim/commit/e6d40dcdc7227594935d2db01eca29f0e575dcee
Author: Ernie Rael <errael@raelity.com>
Date: Sun Mar 19 21:23:38 2023 +0000
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 https://github.com/vim/vim/issues/12183)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 19 Mar 2023 22:30:04 +0100 |
parents | 04d9dff67d99 |
children | 252b06c87796 |
line wrap: on
line diff
--- a/src/dict.c +++ b/src/dict.c @@ -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);