diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-12-16 08:21:09 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-12-16 08:21:09 +0000 |
commit | 2d877599ee1cede063ef4abe3a2272e67c116238 (patch) | |
tree | 9dc9b25997f03c760a6f8f9e05a52c79db028cfa /src/typval.c | |
parent | 19569ca6d805de7a2ac95ee7b0c52475a9d5d851 (diff) | |
download | vim-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/typval.c')
-rw-r--r-- | src/typval.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/typval.c b/src/typval.c index 8dbb939a7..5e1c78c41 100644 --- a/src/typval.c +++ b/src/typval.c @@ -832,6 +832,28 @@ check_for_list_or_dict_or_blob_arg(typval_T *args, int idx) } /* + * Give an error and return FAIL unless "args[idx]" is a list or dict or a + * blob or a string. + */ + int +check_for_list_or_dict_or_blob_or_string_arg(typval_T *args, int idx) +{ + if (args[idx].v_type != VAR_LIST + && args[idx].v_type != VAR_DICT + && args[idx].v_type != VAR_BLOB + && args[idx].v_type != VAR_STRING) + { + if (idx >= 0) + semsg(_(e_list_dict_blob_or_string_required_for_argument_nr), + idx + 1); + else + emsg(_(e_listreq)); + return FAIL; + } + return OK; +} + +/* * Give an error and return FAIL unless "args[idx]" is an optional buffer * number or a dict. */ |