diff src/list.c @ 23565:34aa2907082a v8.2.2325

patch 8.2.2325: Vim9: crash if map() changes the item type Commit: https://github.com/vim/vim/commit/75ab91ff3403e725a79ac9c7351b78e9aff71d67 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jan 10 22:42:50 2021 +0100 patch 8.2.2325: Vim9: crash if map() changes the item type Problem: Vim9: crash if map() changes the item type. Solution: Check that the item type is still OK. (closes https://github.com/vim/vim/issues/7652) Fix problem with mapnew() on range list.
author Bram Moolenaar <Bram@vim.org>
date Sun, 10 Jan 2021 22:45:06 +0100
parents 1bb7fa4f9b35
children 510088f8c66f
line wrap: on
line diff
--- a/src/list.c
+++ b/src/list.c
@@ -2188,10 +2188,13 @@ filter_map(typval_T *argvars, typval_T *
 		int		stride = l->lv_u.nonmat.lv_stride;
 
 		// List from range(): loop over the numbers
-		l->lv_first = NULL;
-		l->lv_u.mat.lv_last = NULL;
-		l->lv_len = 0;
-		l->lv_u.mat.lv_idx_item = NULL;
+		if (filtermap != FILTERMAP_MAPNEW)
+		{
+		    l->lv_first = NULL;
+		    l->lv_u.mat.lv_last = NULL;
+		    l->lv_len = 0;
+		    l->lv_u.mat.lv_idx_item = NULL;
+		}
 
 		for (idx = 0; idx < len; ++idx)
 		{