patch 9.0.0204: indexof() may leak memory
Problem: indexof() may leak memory.
Solution: Free allocated values. (Yegappan Lakshmanan, closes #10916)
diff --git a/src/evalfunc.c b/src/evalfunc.c
index 4f68845..3817352 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -6814,6 +6814,7 @@
return FALSE;
found = tv_get_bool_chk(&newtv, &error);
+ clear_tv(&newtv);
return error ? FALSE : found;
}
@@ -6864,6 +6865,7 @@
{
listitem_T *item;
long idx = 0;
+ int found;
if (l == NULL)
return -1;
@@ -6888,7 +6890,10 @@
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;
}