Patch 8.2.0573
Problem:    using :version twice leaks memory
Solution:   Only initialize variables once. (Dominique Pelle, closes #5917)
Files:      src/testdir/Make_all.mak, src/testdir/test_alot.vim,
            src/testdir/test_version.vim, src/version.c, src/globals.h


*** ../vim-8.2.0572/src/testdir/Make_all.mak    2020-04-07 20:53:35.218912046 
+0200
--- src/testdir/Make_all.mak    2020-04-13 18:17:17.736069275 +0200
***************
*** 285,290 ****
--- 285,291 ----
        test_utf8 \
        test_utf8_comparisons \
        test_vartabs \
+       test_version \
        $(TEST_VIM9) \
        test_viminfo \
        test_vimscript \
*** ../vim-8.2.0572/src/testdir/test_alot.vim   2020-03-19 18:46:53.956641477 
+0100
--- src/testdir/test_alot.vim   2020-04-13 18:17:17.736069275 +0200
***************
*** 32,35 ****
--- 32,36 ----
  source test_tagcase.vim
  source test_tagfunc.vim
  source test_unlet.vim
+ source test_version.vim
  source test_wnext.vim
*** ../vim-8.2.0572/src/testdir/test_version.vim        2020-04-13 
18:24:31.530464173 +0200
--- src/testdir/test_version.vim        2020-04-13 18:17:17.736069275 +0200
***************
*** 0 ****
--- 1,10 ----
+ " Test :version Ex command
+ 
+ func Test_version()
+   " version should always return the same string.
+   let v1 = execute('version')
+   let v2 = execute('version')
+   call assert_equal(v1, v2)
+ 
+   call assert_match("^\n\nVIM - Vi IMproved .*", v1)
+ endfunc
*** ../vim-8.2.0572/src/version.c       2020-04-13 18:13:30.232982723 +0200
--- src/version.c       2020-04-13 18:18:25.403809435 +0200
***************
*** 54,72 ****
      void
  init_longVersion(void)
  {
-     char *date_time = __DATE__ " " __TIME__;
-     char *msg = _("%s (%s, compiled %s)");
-     size_t len = strlen(msg)
-               + strlen(VIM_VERSION_LONG_ONLY)
-               + strlen(VIM_VERSION_DATE_ONLY)
-               + strlen(date_time);
- 
-     longVersion = alloc(len);
      if (longVersion == NULL)
!       longVersion = VIM_VERSION_LONG;
!     else
!       vim_snprintf(longVersion, len, msg,
!                     VIM_VERSION_LONG_ONLY, VIM_VERSION_DATE_ONLY, date_time);
  }
  # endif
  #else
--- 54,75 ----
      void
  init_longVersion(void)
  {
      if (longVersion == NULL)
!     {
!       char *date_time = __DATE__ " " __TIME__;
!       char *msg = _("%s (%s, compiled %s)");
!       size_t len = strlen(msg)
!                   + strlen(VIM_VERSION_LONG_ONLY)
!                   + strlen(VIM_VERSION_DATE_ONLY)
!                   + strlen(date_time);
! 
!       longVersion = alloc(len);
!       if (longVersion == NULL)
!           longVersion = VIM_VERSION_LONG;
!       else
!           vim_snprintf(longVersion, len, msg,
!                         VIM_VERSION_LONG_ONLY, VIM_VERSION_DATE_ONLY, 
date_time);
!     }
  }
  # endif
  #else
*** ../vim-8.2.0572/src/globals.h       2020-04-06 22:12:57.137652853 +0200
--- src/globals.h       2020-04-13 18:22:51.162824700 +0200
***************
*** 1258,1264 ****
  #if defined(HAVE_DATE_TIME) && defined(VMS) && defined(VAXC)
  extern char longVersion[];
  #else
! EXTERN char *longVersion;
  #endif
  
  /*
--- 1258,1264 ----
  #if defined(HAVE_DATE_TIME) && defined(VMS) && defined(VAXC)
  extern char longVersion[];
  #else
! EXTERN char *longVersion INIT(= NULL);
  #endif
  
  /*
*** ../vim-8.2.0572/src/version.c       2020-04-13 18:13:30.232982723 +0200
--- src/version.c       2020-04-13 18:18:25.403809435 +0200
***************
*** 740,741 ****
--- 743,746 ----
  {   /* Add new patch number below this line */
+ /**/
+     573,
  /**/

-- 
If you don't get everything you want, think of
everything you didn't get and don't want.

 /// 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/202004131626.03DGQ00u020881%40masaka.moolenaar.net.

Raspunde prin e-mail lui