Skip to content

Commit

Permalink
patch 8.1.0181: memory leak with trailing characters in skip expression
Browse files Browse the repository at this point in the history
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 a43ebe9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/eval.c
Expand Up @@ -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;
}
Expand Down
10 changes: 10 additions & 0 deletions src/testdir/test_search.vim
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -789,6 +789,8 @@ static char *(features[]) =

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

0 comments on commit a43ebe9

Please sign in to comment.