diff options
author | Yegappan Lakshmanan <yegappan@yahoo.com> | 2022-08-14 12:07:11 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-08-14 12:07:11 +0100 |
commit | 63acae13f57c5ad4c8ec3146d0c458550b9e984e (patch) | |
tree | 50a6a623dcce89ae1f639c4c2e2f62904aee8840 /src/evalfunc.c | |
parent | c9b6570fab46bf2c246a954cfb8c0d95fe2746b3 (diff) |
patch 9.0.0204: indexof() may leak memoryv9.0.0204
Problem: indexof() may leak memory.
Solution: Free allocated values. (Yegappan Lakshmanan, closes #10916)
Diffstat (limited to 'src/evalfunc.c')
-rw-r--r-- | src/evalfunc.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/evalfunc.c b/src/evalfunc.c index 4f68845a16..3817352ca3 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -6814,6 +6814,7 @@ indexof_eval_expr(typval_T *expr) return FALSE; found = tv_get_bool_chk(&newtv, &error); + clear_tv(&newtv); return error ? FALSE : found; } @@ -6864,6 +6865,7 @@ indexof_list(list_T *l, long startidx, typval_T *expr) { listitem_T *item; long idx = 0; + int found; if (l == NULL) return -1; @@ -6888,7 +6890,10 @@ indexof_list(list_T *l, long startidx, typval_T *expr) set_vim_var_nr(VV_KEY, idx); copy_tv(&item->li_tv, get_vim_var_tv(VV_VAL)); - if (indexof_eval_expr(expr)) + found = indexof_eval_expr(expr); + clear_tv(get_vim_var_tv(VV_VAL)); + + if (found) return idx; } |