diff options
author | Bram Moolenaar <Bram@vim.org> | 2018-07-14 17:25:01 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2018-07-14 17:25:01 +0200 |
commit | a43ebe9454386427ca38c75810e2d36991f17812 (patch) | |
tree | 54a2de5b033352d0526495a34d67e3186c54291f | |
parent | d6ef5f9b3d3df2d5dcc666c8741e99fcc77043f6 (diff) | |
download | vim-git-a43ebe9454386427ca38c75810e2d36991f17812.tar.gz |
patch 8.1.0181: memory leak with trailing characters in skip expressionv8.1.0181
Problem: Memory leak with trailing characters in skip expression.
Solution: Free the return value.
-rw-r--r-- | src/eval.c | 1 | ||||
-rw-r--r-- | src/testdir/test_search.vim | 10 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 13 insertions, 0 deletions
diff --git a/src/eval.c b/src/eval.c index 26aa0e34e..4423419b1 100644 --- a/src/eval.c +++ b/src/eval.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; } diff --git a/src/testdir/test_search.vim b/src/testdir/test_search.vim index 9b078be39..28f0463c4 100644 --- a/src/testdir/test_search.vim +++ b/src/testdir/test_search.vim @@ -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 diff --git a/src/version.c b/src/version.c index 727590184..e6a7d8b52 100644 --- a/src/version.c +++ b/src/version.c @@ -790,6 +790,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 181, +/**/ 180, /**/ 179, |