Mercurial > vim
diff src/typval.c @ 26585:0d2a709e2ff0 v8.2.3822
patch 8.2.3822: leaking memory in map() and filter(), no string in Vim9
Commit: https://github.com/vim/vim/commit/2d877599ee1cede063ef4abe3a2272e67c116238
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Dec 16 08:21:09 2021 +0000
patch 8.2.3822: leaking memory in map() and filter(), no string in Vim9
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)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 16 Dec 2021 09:30:04 +0100 |
parents | 65ab0b035dd8 |
children | fac6673086df |
line wrap: on
line diff
--- a/src/typval.c +++ b/src/typval.c @@ -832,6 +832,28 @@ check_for_list_or_dict_or_blob_arg(typva } /* + * 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. */