diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-02-27 00:00:01 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2023-02-27 07:53:17 +0800 |
commit | 1f8cef53deb4b91a7249affca77bfb89ce0949b4 (patch) | |
tree | 6ae8e0d31bc4b08ffbd931061255e6cb1ade485d /src/nvim/eval/funcs.c | |
parent | 13da3d469ae10201de00ae89277c53c40342f4df (diff) | |
download | rneovim-1f8cef53deb4b91a7249affca77bfb89ce0949b4.tar.gz rneovim-1f8cef53deb4b91a7249affca77bfb89ce0949b4.tar.bz2 rneovim-1f8cef53deb4b91a7249affca77bfb89ce0949b4.zip |
vim-patch:9.0.0204: indexof() may leak memory
Problem: indexof() may leak memory.
Solution: Free allocated values. (Yegappan Lakshmanan, closes vim/vim#10916)
https://github.com/vim/vim/commit/63acae13f57c5ad4c8ec3146d0c458550b9e984e
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Diffstat (limited to 'src/nvim/eval/funcs.c')
-rw-r--r-- | src/nvim/eval/funcs.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index 8070dacc48..13d8f52768 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -3505,6 +3505,7 @@ static varnumber_T indexof_eval_expr(typval_T *expr) bool error = false; varnumber_T found = tv_get_bool_chk(&newtv, &error); + tv_clear(&newtv); return error ? false : found; } @@ -3566,7 +3567,10 @@ static varnumber_T indexof_list(list_T *l, varnumber_T startidx, typval_T *expr) set_vim_var_nr(VV_KEY, idx); tv_copy(TV_LIST_ITEM_TV(item), get_vim_var_tv(VV_VAL)); - if (indexof_eval_expr(expr)) { + bool found = indexof_eval_expr(expr); + tv_clear(get_vim_var_tv(VV_VAL)); + + if (found) { return idx; } } |