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/testdir/test_blob.vim b/src/testdir/test_blob.vim
index 46f2d61..46370c4 100644
--- a/src/testdir/test_blob.vim
+++ b/src/testdir/test_blob.vim
@@ -772,6 +772,7 @@
   call assert_equal(-1, indexof(b, {i, v -> v == 0x1}))
   call assert_equal(1, indexof(b, "v:val == 0xad"))
   call assert_equal(-1, indexof(b, "v:val == 0xff"))
+  call assert_equal(-1, indexof(b, {_, v -> "v == 0xad"}))
 
   call assert_equal(-1, indexof(0z, "v:val == 0x0"))
   call assert_equal(-1, indexof(test_null_blob(), "v:val == 0xde"))
diff --git a/src/testdir/test_listdict.vim b/src/testdir/test_listdict.vim
index 2c4e5c7..bba4e3e 100644
--- a/src/testdir/test_listdict.vim
+++ b/src/testdir/test_listdict.vim
@@ -1462,7 +1462,13 @@
   call assert_equal(-1, indexof(l, "v:val.n == 10", #{startidx: -4}))
   call assert_equal(0, indexof(l, "v:val.n == 10", test_null_dict()))
 
+  let s = ["a", "b", "c"]
+  call assert_equal(2, indexof(s, {_, v -> v == 'c'}))
+  call assert_equal(-1, indexof(s, {_, v -> v == 'd'}))
+  call assert_equal(-1, indexof(s, {_, v -> "v == 'd'"}))
+
   call assert_equal(-1, indexof([], {i, v -> v == 'a'}))
+  call assert_equal(-1, indexof([1, 2, 3], {_, v -> "v == 2"}))
   call assert_equal(-1, indexof(test_null_list(), {i, v -> v == 'a'}))
   call assert_equal(-1, indexof(l, test_null_string()))
   call assert_equal(-1, indexof(l, test_null_function()))
diff --git a/src/testdir/test_vim9_builtin.vim b/src/testdir/test_vim9_builtin.vim
index 244021c..55ede98 100644
--- a/src/testdir/test_vim9_builtin.vim
+++ b/src/testdir/test_vim9_builtin.vim
@@ -2074,10 +2074,36 @@
   var b = 0zdeadbeef
   indexof(b, "v:val == 0xef")->assert_equal(3)
 
-  def TestIdx(k: number, v: dict<any>): bool
+  def TestIdx1(k: number, v: dict<any>): bool
     return v.color == 'blue'
   enddef
-  indexof(l, TestIdx)->assert_equal(1)
+  indexof(l, TestIdx1)->assert_equal(1)
+
+  var lines =<< trim END
+    def TestIdx(v: dict<any>): bool
+      return v.color == 'blue'
+    enddef
+
+    indexof([{color: "red"}], TestIdx)
+  END
+  v9.CheckDefAndScriptFailure(lines, ['E176: Invalid number of arguments', 'E118: Too many arguments for function'])
+
+  lines =<< trim END
+    def TestIdx(k: number, v: dict<any>)
+    enddef
+
+    indexof([{color: "red"}], TestIdx)
+  END
+  v9.CheckDefAndScriptFailure(lines, ['E1013: Argument 2: type mismatch, expected func(?number, ?any): bool', 'E1031: Cannot use void value'])
+
+  lines =<< trim END
+    def TestIdx(k: number, v: dict<any>): string
+      return "abc"
+    enddef
+
+    indexof([{color: "red"}], TestIdx)
+  END
+  v9.CheckDefAndScriptFailure(lines, ['E1013: Argument 2: type mismatch, expected func(?number, ?any): bool', 'E1135: Using a String as a Bool'])
 enddef
 
 def Test_input()