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 -- [email protected] -- 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    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202004022058.032Kw64p027657%40masaka.moolenaar.net.

Raspunde prin e-mail lui