summaryrefslogtreecommitdiffstats
path: root/src/evalfunc.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/evalfunc.c
parent19569ca6d805de7a2ac95ee7b0c52475a9d5d851 (diff)
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/evalfunc.c')
-rw-r--r--src/evalfunc.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/evalfunc.c b/src/evalfunc.c
index b6f3d8982d..25fcc45722 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -449,6 +449,22 @@ arg_list_or_dict_or_blob(type_T *type, argcontext_T *context)
}
/*
+ * Check "type" is a list of 'any' or a dict of 'any' or a blob or a string.
+ */
+ static int
+arg_list_or_dict_or_blob_or_string(type_T *type, argcontext_T *context)
+{
+ if (type->tt_type == VAR_ANY
+ || type->tt_type == VAR_LIST
+ || type->tt_type == VAR_DICT
+ || type->tt_type == VAR_BLOB
+ || type->tt_type == VAR_STRING)
+ return OK;
+ arg_type_mismatch(&t_list_any, type, context->arg_idx + 1);
+ return FAIL;
+}
+
+/*
* Check "type" is a job.
*/
static int
@@ -797,7 +813,7 @@ static argcheck_T arg23_insert[] = {arg_list_or_blob, arg_item_of_prev, arg_numb
static argcheck_T arg1_len[] = {arg_len1};
static argcheck_T arg3_libcall[] = {arg_string, arg_string, arg_string_or_nr};
static argcheck_T arg14_maparg[] = {arg_string, arg_string, arg_bool, arg_bool};
-static argcheck_T arg2_mapfilter[] = {arg_list_or_dict_or_blob, NULL};
+static argcheck_T arg2_mapfilter[] = {arg_list_or_dict_or_blob_or_string, NULL};
static argcheck_T arg25_matchadd[] = {arg_string, arg_string, arg_number, arg_number, arg_dict_any};
static argcheck_T arg25_matchaddpos[] = {arg_string, arg_list_any, arg_number, arg_number, arg_dict_any};
static argcheck_T arg119_printf[] = {arg_string_or_nr, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};