Patch 8.2.3059 (after 8.2.3056)
Problem:    Vim9: memory leak when using lambda.
Solution:   Do not store the default value strings when skipping.
Files:      src/userfunc.c


*** ../vim-8.2.3058/src/userfunc.c      2021-06-26 21:51:58.510221846 +0200
--- src/userfunc.c      2021-06-26 22:15:43.727214172 +0200
***************
*** 198,204 ****
        ga_init2(newargs, (int)sizeof(char_u *), 3);
      if (argtypes != NULL)
        ga_init2(argtypes, (int)sizeof(char_u *), 3);
!     if (default_args != NULL)
        ga_init2(default_args, (int)sizeof(char_u *), 3);
  
      if (varargs != NULL)
--- 198,204 ----
        ga_init2(newargs, (int)sizeof(char_u *), 3);
      if (argtypes != NULL)
        ga_init2(argtypes, (int)sizeof(char_u *), 3);
!     if (!skip && default_args != NULL)
        ga_init2(default_args, (int)sizeof(char_u *), 3);
  
      if (varargs != NULL)
***************
*** 289,312 ****
                expr = p;
                if (eval1(&p, &rettv, NULL) != FAIL)
                {
!                   if (ga_grow(default_args, 1) == FAIL)
!                       goto err_ret;
! 
!                   // trim trailing whitespace
!                   while (p > expr && VIM_ISWHITE(p[-1]))
!                       p--;
!                   c = *p;
!                   *p = NUL;
!                   expr = vim_strsave(expr);
!                   if (expr == NULL)
                    {
                        *p = c;
-                       goto err_ret;
                    }
-                   ((char_u **)(default_args->ga_data))
-                                                [default_args->ga_len] = expr;
-                   default_args->ga_len++;
-                   *p = c;
                }
                else
                    mustend = TRUE;
--- 289,315 ----
                expr = p;
                if (eval1(&p, &rettv, NULL) != FAIL)
                {
!                   if (!skip)
                    {
+                       if (ga_grow(default_args, 1) == FAIL)
+                           goto err_ret;
+ 
+                       // trim trailing whitespace
+                       while (p > expr && VIM_ISWHITE(p[-1]))
+                           p--;
+                       c = *p;
+                       *p = NUL;
+                       expr = vim_strsave(expr);
+                       if (expr == NULL)
+                       {
+                           *p = c;
+                           goto err_ret;
+                       }
+                       ((char_u **)(default_args->ga_data))
+                                                [default_args->ga_len] = expr;
+                       default_args->ga_len++;
                        *p = c;
                    }
                }
                else
                    mustend = TRUE;
***************
*** 357,363 ****
  err_ret:
      if (newargs != NULL)
        ga_clear_strings(newargs);
!     if (default_args != NULL)
        ga_clear_strings(default_args);
      return FAIL;
  }
--- 360,366 ----
  err_ret:
      if (newargs != NULL)
        ga_clear_strings(newargs);
!     if (!skip && default_args != NULL)
        ga_clear_strings(default_args);
      return FAIL;
  }
*** ../vim-8.2.3058/src/version.c       2021-06-26 21:51:58.514221840 +0200
--- src/version.c       2021-06-26 22:17:18.559029748 +0200
***************
*** 757,758 ****
--- 757,760 ----
  {   /* Add new patch number below this line */
+ /**/
+     3059,
  /**/

-- 
Seen it all, done it all, can't remember most of it.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            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/202106262018.15QKIUda438392%40masaka.moolenaar.net.

Raspunde prin e-mail lui