]> granicus.if.org Git - vim/commitdiff
patch 8.1.0181: memory leak with trailing characters in skip expression v8.1.0181
authorBram Moolenaar <Bram@vim.org>
Sat, 14 Jul 2018 15:25:01 +0000 (17:25 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 14 Jul 2018 15:25:01 +0000 (17:25 +0200)
Problem:    Memory leak with trailing characters in skip expression.
Solution:   Free the return value.

src/eval.c
src/testdir/test_search.vim
src/version.c

index 26aa0e34e71d778620cc69bf9f845c8eed7fe250..4423419b17e858299ed1cd8564d06503c495038d 100644 (file)
@@ -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;
        }
index 9b078be396dae7abff2cae82fe4231197287d7f5..28f0463c4015141d307f7b309900be2662f0a74b 100644 (file)
@@ -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
index 72759018435fd169b735a69bc508705139c26220..e6a7d8b52b5525e756e7504dda5a192653e44c78 100644 (file)
@@ -789,6 +789,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    181,
 /**/
     180,
 /**/