From f0d6695e7cc13cd5f1ee006575a369faf2546893 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Fri, 21 Jun 2019 20:46:43 -0400 Subject: vim-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. https://github.com/vim/vim/commit/a43ebe9454386427ca38c75810e2d36991f17812 --- src/nvim/eval.c | 1 + src/nvim/testdir/test_search.vim | 10 ++++++++++ 2 files changed, 11 insertions(+) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 3c50647848..3e6e183847 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -991,6 +991,7 @@ static int eval_expr_typval(const typval_T *expr, typval_T *argv, return FAIL; } if (*s != NUL) { // check for trailing chars after expr + tv_clear(rettv); emsgf(_(e_invexpr2), s); return FAIL; } diff --git a/src/nvim/testdir/test_search.vim b/src/nvim/testdir/test_search.vim index c455279a59..5e5ec96fd1 100644 --- a/src/nvim/testdir/test_search.vim +++ b/src/nvim/testdir/test_search.vim @@ -325,6 +325,16 @@ func Test_searchpair_skip() 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('\\', '\\', '\\', '', '\"foo\" 2')", 'E15:') + + bwipe! +endfunc + func Test_searchc() " These commands used to cause memory overflow in searchc(). new -- cgit