]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1331: Leaking memory with cmdcomplete() v9.1.1331
authorGirish Palya <girishji@gmail.com>
Tue, 22 Apr 2025 17:52:16 +0000 (19:52 +0200)
committerChristian Brabandt <cb@256bit.org>
Tue, 22 Apr 2025 17:52:16 +0000 (19:52 +0200)
Problem:  Leaking memory with cmdcomplete()
          (zeertzjq, after v9.1.1329)
Solution: free the memory (Girish Palya)

closes: #17190

Signed-off-by: Girish Palya <girishji@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/doc/builtin.txt
src/cmdexpand.c
src/ex_getln.c
src/testdir/test_autocmd.vim
src/version.c

index 70f3c88e3a7e76be9fef27ae21fce6ffe3f8feed..0a1c3b12720ee2aef5535780d6e35b34d6b68a34 100644 (file)
@@ -1,4 +1,4 @@
-*builtin.txt*  For Vim version 9.1.  Last change: 2025 Apr 21
+*builtin.txt*  For Vim version 9.1.  Last change: 2025 Apr 23
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -1834,7 +1834,7 @@ clearmatches([{win}])                                     *clearmatches()*
                Return type: |Number|
 
 
-cmdcomplete_info([{what}])                             *cmdcomplete_info()*
+cmdcomplete_info()                                     *cmdcomplete_info()*
                Returns a |Dictionary| with information about cmdline
                completion.  See |cmdline-completion|.
                The items are:
index 45f69bb2fe9287f6ed9508bb272e53eadcbb92a9..5b87d7804a612388295e0d7e3c25f2fff07cd35a 100644 (file)
@@ -1244,7 +1244,10 @@ showmatches(expand_T *xp, int wildmenu UNUSED)
 
     // Save cmdline before expansion
     if (ccline->cmdbuff != NULL)
+    {
+       vim_free(cmdline_orig);
        cmdline_orig = vim_strnsave(ccline->cmdbuff, ccline->cmdlen);
+    }
 
     if (xp->xp_numfiles == -1)
     {
index 1137708aebf772b88e8c857cd312a7bb02b77c4f..8445236acc77bbaa93ea7aafa6b9bb954ddd789d 100644 (file)
@@ -1916,8 +1916,7 @@ getcmdline_int(
        }
 
        // Trigger CmdlineLeavePre autocommand
-       if (ccline.cmdfirstc != NUL && (c == '\n' || c == '\r' || c == K_KENTER
-                   || c == ESC || c == Ctrl_C))
+       if (c == '\n' || c == '\r' || c == K_KENTER || c == ESC || c == Ctrl_C)
            trigger_cmd_autocmd(cmdline_type, EVENT_CMDLINELEAVEPRE);
 
        // The wildmenu is cleared if the pressed key is not used for
index ae587117e47eba2ea803347a521b00f21074655b..6f83b9caeae971235d9b8246c341847497c4b7e9 100644 (file)
@@ -2038,6 +2038,12 @@ func Test_Cmdline_Trigger()
   call assert_equal('', g:log)
   call feedkeys(":echo hello", "tx")
   call assert_equal('CmdlineLeavePre', g:log)
+  let g:count = 0
+  autocmd CmdlineLeavePre * let g:count += 1
+  call feedkeys(":let c = input('? ')\<cr>B\<cr>", "tx")
+  call assert_equal(2, g:count)
+  unlet! g:count
+  unlet! g:log
   bw!
 endfunc
 
index 048788e60fc7c2f57c015c0b32a8b99e724cd1a4..2209282f817bf61f87382b67042bb78b0760f291 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1331,
 /**/
     1330,
 /**/