summaryrefslogtreecommitdiff
path: root/src/list.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-12-16 08:21:09 +0000
committerBram Moolenaar <Bram@vim.org>2021-12-16 08:21:09 +0000
commit2d877599ee1cede063ef4abe3a2272e67c116238 (patch)
tree9dc9b25997f03c760a6f8f9e05a52c79db028cfa /src/list.c
parent19569ca6d805de7a2ac95ee7b0c52475a9d5d851 (diff)
downloadvim-git-2d877599ee1cede063ef4abe3a2272e67c116238.tar.gz
patch 8.2.3822: leaking memory in map() and filter(), no string in Vim9v8.2.3822
Problem: Leaking memory in map() and filter(), cannot use a string argument in Vim9 script. Solution: Fix the leak, adjust the argument check, also run the tests as Vim9 script. (Yegappan Lakshmanan, closes #9354)
Diffstat (limited to 'src/list.c')
-rw-r--r--src/list.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/list.c b/src/list.c
index ff22de6fd..fafe4655a 100644
--- a/src/list.c
+++ b/src/list.c
@@ -2281,11 +2281,12 @@ filter_map(typval_T *argvars, typval_T *rettv, filtermap_T filtermap)
garray_T type_list;
// map() and filter() return the first argument, also on failure.
- if (filtermap != FILTERMAP_MAPNEW)
+ if (filtermap != FILTERMAP_MAPNEW && argvars[0].v_type != VAR_STRING)
copy_tv(&argvars[0], rettv);
if (in_vim9script()
- && (check_for_list_or_dict_or_blob_arg(argvars, 0) == FAIL))
+ && (check_for_list_or_dict_or_blob_or_string_arg(argvars, 0)
+ == FAIL))
return;
if (filtermap == FILTERMAP_MAP && in_vim9script())