neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit bc0c7dde17ab71b39db2a03086dec5694e083a40
parent 8cbb2477cf70ea29105e3df17308e6d6a067c8e6
Author: zeertzjq <zeertzjq@outlook.com>
Date:   Thu, 17 Aug 2023 10:44:32 +0800

vim-patch:8.2.1971: memory leak when map() fails

Problem:    Memory leak when map() fails.
Solution:   Clear the typval.

https://github.com/vim/vim/commit/c56936e2ba4fd219f56aab616fcb283132455697

Co-authored-by: Bram Moolenaar <Bram@vim.org>

Diffstat:
Msrc/nvim/eval.c | 7+++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/nvim/eval.c b/src/nvim/eval.c @@ -5217,8 +5217,11 @@ static void filter_map(typval_T *argvars, typval_T *rettv, filtermap_T filtermap } vimvars[VV_KEY].vv_nr = idx; typval_T newtv; - if (filter_map_one(TV_LIST_ITEM_TV(li), expr, filtermap, &newtv, &rem) == FAIL - || did_emsg) { + if (filter_map_one(TV_LIST_ITEM_TV(li), expr, filtermap, &newtv, &rem) == FAIL) { + break; + } + if (did_emsg) { + tv_clear(&newtv); break; } if (filtermap == FILTERMAP_MAP) {