diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-05-07 23:20:21 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-05-07 23:20:21 +0200 |
commit | 5c2fe644430efabf9dadfb89a9f1e82367eaf28d (patch) | |
tree | 43bdaf62be49cf4b4b426947592bd11d8b6e1124 | |
parent | cca34aa4bef5327eb4025850045c4c980ef4354b (diff) | |
download | vim-git-5c2fe644430efabf9dadfb89a9f1e82367eaf28d.tar.gz |
patch 8.2.0716: Vim9: another memory leakv8.2.0716
Problem: Vim9: another memory leak.
Solution: Clear typval when failing.
-rw-r--r-- | src/version.c | 2 | ||||
-rw-r--r-- | src/vim9compile.c | 19 |
2 files changed, 17 insertions, 4 deletions
diff --git a/src/version.c b/src/version.c index 743448649..c8361eba1 100644 --- a/src/version.c +++ b/src/version.c @@ -747,6 +747,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 716, +/**/ 715, /**/ 714, diff --git a/src/vim9compile.c b/src/vim9compile.c index 3d3b3c30f..67ca3de66 100644 --- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -4074,12 +4074,16 @@ compile_expr7( return FAIL; } + // Handle following "[]", ".member", etc. + // Then deal with prefixed '-', '+' and '!', if not done already. if (compile_subscript(arg, cctx, &start_leader, end_leader, - bef1_tv, bef2_tv, new_tv) == FAIL) + bef1_tv, bef2_tv, new_tv) == FAIL + || compile_leader(cctx, start_leader, end_leader) == FAIL) + { + clear_tv(new_tv); return FAIL; - - // Now deal with prefixed '-', '+' and '!', if not done already. - return compile_leader(cctx, start_leader, end_leader); + } + return OK; } /* @@ -4187,6 +4191,7 @@ compile_expr5(char_u **arg, cctx_T *cctx) { char_u buf[3]; + clear_tv(&tv1); vim_strncpy(buf, op, oplen); semsg(_(e_white_both), buf); return FAIL; @@ -4194,12 +4199,18 @@ compile_expr5(char_u **arg, cctx_T *cctx) *arg = skipwhite(op + oplen); if (may_get_next_line(op + oplen, arg, cctx) == FAIL) + { + clear_tv(&tv1); return FAIL; + } // get the second expression tv2.v_type = VAR_UNKNOWN; if (compile_expr6(arg, cctx, &tv1, &tv2) == FAIL) + { + clear_tv(&tv1); return FAIL; + } if (*op == '+' && tv1.v_type == VAR_NUMBER && tv2.v_type == VAR_NUMBER) { |