diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-12-01 10:10:22 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-12-01 10:10:22 +0000 |
commit | 56a8ffdb6e903615ed824a503f5fa6382b5b3df5 (patch) | |
tree | bae71cde0d9877bfbf21784e21f13c6cb46d1716 | |
parent | 3d2e031d4f0e1559e4a4f99de5eb2330f38f8eb5 (diff) |
patch 8.2.3711: Vim9: memory leak when compiling :elseif failsv8.2.3711
Problem: Vim9: memory leak when compiling :elseif fails.
Solution: Cleanup ppconst.
-rw-r--r-- | src/testdir/test_vim9_cmd.vim | 13 | ||||
-rw-r--r-- | src/version.c | 2 | ||||
-rw-r--r-- | src/vim9compile.c | 4 |
3 files changed, 17 insertions, 2 deletions
diff --git a/src/testdir/test_vim9_cmd.vim b/src/testdir/test_vim9_cmd.vim index ece3f734f0..22b1896a1d 100644 --- a/src/testdir/test_vim9_cmd.vim +++ b/src/testdir/test_vim9_cmd.vim @@ -301,12 +301,21 @@ def Test_condition_types() CheckDefAndScriptFailure(lines, 'E1135:', 3) lines =<< trim END + g:cond = 0 + if g:cond + elseif 'text' garbage + endif + END + CheckDefAndScriptFailure(lines, 'E488:', 3) + + lines =<< trim END + g:cond = 0 if g:cond elseif [1] endif END - CheckDefFailure(lines, 'E1012:', 2) - CheckScriptFailure(['vim9script'] + lines, 'E745:', 3) + CheckDefFailure(lines, 'E1012:', 3) + CheckScriptFailure(['vim9script'] + lines, 'E745:', 4) lines =<< trim END g:cond = 'text' diff --git a/src/version.c b/src/version.c index 37d383247b..4890e2cde1 100644 --- a/src/version.c +++ b/src/version.c @@ -754,6 +754,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 3711, +/**/ 3710, /**/ 3709, diff --git a/src/vim9compile.c b/src/vim9compile.c index 3f72c7f39a..2ed1f0e58e 100644 --- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -7888,6 +7888,7 @@ compile_elseif(char_u *arg, cctx_T *cctx) cctx->ctx_skip = save_skip; if (!ends_excmd2(arg, skipwhite(p))) { + clear_ppconst(&ppconst); semsg(_(e_trailing_arg), p); return NULL; } @@ -7901,7 +7902,10 @@ compile_elseif(char_u *arg, cctx_T *cctx) // The expression result is a constant. v = tv_get_bool_chk(&ppconst.pp_tv[0], &error); if (error) + { + clear_ppconst(&ppconst); return NULL; + } cctx->ctx_skip = v ? SKIP_NOT : SKIP_YES; clear_ppconst(&ppconst); scope->se_u.se_if.is_if_label = -1; |