To: vim_dev@googlegroups.com Subject: Patch 8.2.0504 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.0504 Problem: Vim9: leaking scope memory when compilation fails. Solution: Cleanup the scope list. Files: src/vim9compile.c *** ../vim-8.2.0503/src/vim9compile.c 2020-04-02 22:33:17.868287352 +0200 --- src/vim9compile.c 2020-04-02 22:55:12.776429974 +0200 *************** *** 3995,4000 **** --- 3995,4012 ---- } } + 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,4031 **** --- 4038,4057 ---- 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,5524 **** --- 5545,5553 ---- 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); *** ../vim-8.2.0503/src/version.c 2020-04-02 22:33:17.868287352 +0200 --- src/version.c 2020-04-02 22:45:54.702212683 +0200 *************** *** 740,741 **** --- 740,743 ---- { /* Add new patch number below this line */ + /**/ + 504, /**/ -- Dreams are free, but there's a small charge for alterations. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///