Permalink
Browse files

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.
  • Loading branch information...
brammool committed Jul 14, 2018
1 parent d6ef5f9 commit a43ebe9454386427ca38c75810e2d36991f17812
Showing with 13 additions and 0 deletions.
  1. +1 −0 src/eval.c
  2. +10 −0 src/testdir/test_search.vim
  3. +2 −0 src/version.c
@@ -729,6 +729,7 @@ eval_expr_typval(typval_T *expr, typval_T *argv, int argc, typval_T *rettv)
return FAIL;
if (*s != NUL) /* check for trailing chars after expr */
{
clear_tv(rettv);
EMSG2(_(e_invexpr2), s);
return FAIL;
}
@@ -324,6 +324,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('\\<if\\>', '\\<else\\>', '\\<endif\\>', '', '\"foo\" 2')", 'E15:')

bwipe!
endfunc

func Test_searchc()
" These commands used to cause memory overflow in searchc().
new
@@ -789,6 +789,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
181,
/**/
180,
/**/

0 comments on commit a43ebe9

Please sign in to comment.