From 83a48d7a44c69a8b159bdcf90029005f2f4a8de5 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Sat, 1 Jan 2022 07:51:13 +0000 Subject: vim-patch:8.2.2661: leaking memory when looping over a string Problem: Leaking memory when looping over a string. Solution: Free the memory. https://github.com/vim/vim/commit/bb5d87c8504588be9c9d2fecc5b6455a2b2f6201 --- src/nvim/eval.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index aecb23f251..b4baeb5240 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -2698,7 +2698,10 @@ bool next_for_item(void *fi_void, char_u *arg) tv.v_lock = VAR_FIXED; tv.vval.v_string = vim_strnsave(fi->fi_string + fi->fi_byte_idx, len); fi->fi_byte_idx += len; - return ex_let_vars(arg, &tv, true, fi->fi_semicolon, fi->fi_varcount, false, NULL) == OK; + const int result + = ex_let_vars(arg, &tv, true, fi->fi_semicolon, fi->fi_varcount, false, NULL) == OK; + xfree(tv.vval.v_string); + return result; } listitem_T *item = fi->fi_lw.lw_item; -- cgit