aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/eval.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-01-16 09:32:57 +0800
committerGitHub <noreply@github.com>2024-01-16 09:32:57 +0800
commita34451982fe661fcfb6082607a8cf4c22ff51577 (patch)
tree1d3d6fc8d53ab937a0d153f6562a901baa0dc01b /src/nvim/eval.c
parent73e1942abe7a96d63ce3749af4187f2cdff87e69 (diff)
downloadrneovim-a34451982fe661fcfb6082607a8cf4c22ff51577.tar.gz
rneovim-a34451982fe661fcfb6082607a8cf4c22ff51577.tar.bz2
rneovim-a34451982fe661fcfb6082607a8cf4c22ff51577.zip
vim-patch:8.1.1968: crash when using nested map() (#27029)
Problem: Crash when using nested map(). Solution: Clear the pointer in prepare_vimvar(). (Ozaki Kiichi, closes vim/vim#4890, closes vim/vim#4891) https://github.com/vim/vim/commit/27da7de7c547dbf983ed7dd901ea59be4e7c9ab2 Cherry-pick Test_filter_map_nested() from patch 8.1.1964. Co-authored-by: Bram Moolenaar <Bram@vim.org>
Diffstat (limited to 'src/nvim/eval.c')
-rw-r--r--src/nvim/eval.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 5826316828..ad2ff89f7e 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -1095,17 +1095,19 @@ bool is_compatht(const hashtab_T *ht)
}
/// Prepare v: variable "idx" to be used.
-/// Save the current typeval in "save_tv".
+/// Save the current typeval in "save_tv" and clear it.
/// When not used yet add the variable to the v: hashtable.
void prepare_vimvar(int idx, typval_T *save_tv)
{
*save_tv = vimvars[idx].vv_tv;
+ vimvars[idx].vv_str = NULL; // don't free it now
if (vimvars[idx].vv_type == VAR_UNKNOWN) {
hash_add(&vimvarht, vimvars[idx].vv_di.di_key);
}
}
/// Restore v: variable "idx" to typeval "save_tv".
+/// Note that the v: variable must have been cleared already.
/// When no longer defined, remove the variable from the v: hashtable.
void restore_vimvar(int idx, typval_T *save_tv)
{