diff src/list.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 06693d1afc48
children 6fd15d82e898
line wrap: on
line diff
--- a/src/list.c
+++ b/src/list.c
@@ -2281,11 +2281,12 @@ filter_map(typval_T *argvars, typval_T *
     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())