diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-04-02 22:57:36 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-04-02 22:57:36 +0200 |
commit | 3cca299520a4980fd1b124564bd67782ca977c15 (patch) | |
tree | f7bf858d71cba36253359447eab61bacefed64ff | |
parent | 585fea7b98b79f2c6d92fa8a2340e461aff805c8 (diff) |
patch 8.2.0504: Vim9: leaking scope memory when compilation failsv8.2.0504
Problem: Vim9: leaking scope memory when compilation fails.
Solution: Cleanup the scope list.
-rw-r--r-- | src/version.c | 2 | ||||
-rw-r--r-- | src/vim9compile.c | 29 |
2 files changed, 31 insertions, 0 deletions
diff --git a/src/version.c b/src/version.c index 528454b232..0e7e8c281e 100644 --- a/src/version.c +++ b/src/version.c @@ -739,6 +739,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 504, +/**/ 503, /**/ 502, diff --git a/src/vim9compile.c b/src/vim9compile.c index 8366172054..3ce04a14a9 100644 --- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -3995,6 +3995,18 @@ compile_fill_jump_to_end(endlabel_T **el, cctx_T *cctx) } } + static void +compile_free_jump_to_end(endlabel_T **el) +{ + while (*el != NULL) + { + endlabel_T *cur = (*el); + + *el = cur->el_next; + vim_free(cur); + } +} + /* * Create a new scope and set up the generic items. */ @@ -4026,6 +4038,20 @@ drop_scope(cctx_T *cctx) return; } cctx->ctx_scope = scope->se_outer; + switch (scope->se_type) + { + case IF_SCOPE: + compile_free_jump_to_end(&scope->se_u.se_if.is_end_label); break; + case FOR_SCOPE: + compile_free_jump_to_end(&scope->se_u.se_for.fs_end_label); break; + case WHILE_SCOPE: + compile_free_jump_to_end(&scope->se_u.se_while.ws_end_label); break; + case TRY_SCOPE: + compile_free_jump_to_end(&scope->se_u.se_try.ts_end_label); break; + case NO_SCOPE: + case BLOCK_SCOPE: + break; + } vim_free(scope); } @@ -5519,6 +5545,9 @@ erret: if (!dfunc->df_deleted) --def_functions.ga_len; + while (cctx.ctx_scope != NULL) + drop_scope(&cctx); + // Don't execute this function body. ga_clear_strings(&ufunc->uf_lines); |