patch 8.1.0181: memory leak with trailing characters in skip expression
Problem: Memory leak with trailing characters in skip expression.
Solution: Free the return value.
diff --git a/src/eval.c b/src/eval.c
index 26aa0e3..4423419 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -729,6 +729,7 @@
return FAIL;
if (*s != NUL) /* check for trailing chars after expr */
{
+ clear_tv(rettv);
EMSG2(_(e_invexpr2), s);
return FAIL;
}
diff --git a/src/testdir/test_search.vim b/src/testdir/test_search.vim
index 9b078be..28f0463 100644
--- a/src/testdir/test_search.vim
+++ b/src/testdir/test_search.vim
@@ -324,6 +324,16 @@
bw!
endfunc
+func Test_searchpair_leak()
+ new
+ call setline(1, 'if one else another endif')
+
+ " The error in the skip expression caused memory to leak.
+ call assert_fails("call searchpair('\\<if\\>', '\\<else\\>', '\\<endif\\>', '', '\"foo\" 2')", 'E15:')
+
+ bwipe!
+endfunc
+
func Test_searchc()
" These commands used to cause memory overflow in searchc().
new
diff --git a/src/version.c b/src/version.c
index 7275901..e6a7d8b 100644
--- a/src/version.c
+++ b/src/version.c
@@ -790,6 +790,8 @@
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 181,
+/**/
180,
/**/
179,