summaryrefslogtreecommitdiffstats
path: root/src/eval.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-09-02 20:44:07 +0200
committerBram Moolenaar <Bram@vim.org>2019-09-02 20:44:07 +0200
commitc36350bca3eed8ef97061e28c38b5b89cae1f13e (patch)
tree0dc30d2da4cab8f05a58583e9044ca594c463da1 /src/eval.c
parent934470e562df7bc778ff916db44918f3ccecc7cc (diff)
patch 8.1.1964: crash when using nested map() and filter()v8.1.1964
Problem: Crash when using nested map() and filter(). Solution: Do not set the v:key type to string without clearing the pointer.
Diffstat (limited to 'src/eval.c')
-rw-r--r--src/eval.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/eval.c b/src/eval.c
index e75624345a..8da8205d50 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -7185,8 +7185,6 @@ filter_map(typval_T *argvars, typval_T *rettv, int map)
hashtab_T *ht;
hashitem_T *hi;
dict_T *d = NULL;
- typval_T save_val;
- typval_T save_key;
blob_T *b = NULL;
int rem;
int todo;
@@ -7225,18 +7223,19 @@ filter_map(typval_T *argvars, typval_T *rettv, int map)
* was not passed as argument. */
if (expr->v_type != VAR_UNKNOWN)
{
+ typval_T save_val;
+ typval_T save_key;
+
prepare_vimvar(VV_VAL, &save_val);
+ prepare_vimvar(VV_KEY, &save_key);
- /* We reset "did_emsg" to be able to detect whether an error
- * occurred during evaluation of the expression. */
+ // We reset "did_emsg" to be able to detect whether an error
+ // occurred during evaluation of the expression.
save_did_emsg = did_emsg;
did_emsg = FALSE;
- prepare_vimvar(VV_KEY, &save_key);
if (argvars[0].v_type == VAR_DICT)
{
- set_vim_var_type(VV_KEY, VAR_STRING);
-
ht = &d->dv_hashtab;
hash_lock(ht);
todo = (int)ht->ht_used;
@@ -7274,7 +7273,9 @@ filter_map(typval_T *argvars, typval_T *rettv, int map)
int i;
typval_T tv;
+ // set_vim_var_nr() doesn't set the type
set_vim_var_type(VV_KEY, VAR_NUMBER);
+
for (i = 0; i < b->bv_ga.ga_len; i++)
{
tv.v_type = VAR_NUMBER;
@@ -7285,7 +7286,7 @@ filter_map(typval_T *argvars, typval_T *rettv, int map)
if (tv.v_type != VAR_NUMBER)
{
emsg(_(e_invalblob));
- return;
+ break;
}
tv.v_type = VAR_NUMBER;
blob_set(b, i, tv.vval.v_number);
@@ -7300,9 +7301,9 @@ filter_map(typval_T *argvars, typval_T *rettv, int map)
}
}
}
- else
+ else // argvars[0].v_type == VAR_LIST
{
- // argvars[0].v_type == VAR_LIST
+ // set_vim_var_nr() doesn't set the type
set_vim_var_type(VV_KEY, VAR_NUMBER);
for (li = l->lv_first; li != NULL; li = nli)