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.
a43ebe9454
This commit is contained in:
Jan Edmund Lazo
2019-06-21 20:46:43 -04:00
parent 6eae28f090
commit f0d6695e7c
2 changed files with 11 additions and 0 deletions

View File

@@ -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;
}

View File

@@ -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('\\<if\\>', '\\<else\\>', '\\<endif\\>', '', '\"foo\" 2')", 'E15:')
bwipe!
endfunc
func Test_searchc()
" These commands used to cause memory overflow in searchc().
new