1
0
forked from aniani/vim

patch 9.1.1331: Leaking memory with cmdcomplete()

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>
This commit is contained in:
Girish Palya 2025-04-22 19:52:16 +02:00 committed by Christian Brabandt
parent fa3b1043c6
commit 5c3d1e3258
No known key found for this signature in database
GPG Key ID: F3F92DA383FDDE09
5 changed files with 14 additions and 4 deletions

View 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 VIM REFERENCE MANUAL by Bram Moolenaar
@ -1834,7 +1834,7 @@ clearmatches([{win}]) *clearmatches()*
Return type: |Number| Return type: |Number|
cmdcomplete_info([{what}]) *cmdcomplete_info()* cmdcomplete_info() *cmdcomplete_info()*
Returns a |Dictionary| with information about cmdline Returns a |Dictionary| with information about cmdline
completion. See |cmdline-completion|. completion. See |cmdline-completion|.
The items are: The items are:

View File

@ -1244,7 +1244,10 @@ showmatches(expand_T *xp, int wildmenu UNUSED)
// Save cmdline before expansion // Save cmdline before expansion
if (ccline->cmdbuff != NULL) if (ccline->cmdbuff != NULL)
{
vim_free(cmdline_orig);
cmdline_orig = vim_strnsave(ccline->cmdbuff, ccline->cmdlen); cmdline_orig = vim_strnsave(ccline->cmdbuff, ccline->cmdlen);
}
if (xp->xp_numfiles == -1) if (xp->xp_numfiles == -1)
{ {

View File

@ -1916,8 +1916,7 @@ getcmdline_int(
} }
// Trigger CmdlineLeavePre autocommand // Trigger CmdlineLeavePre autocommand
if (ccline.cmdfirstc != NUL && (c == '\n' || c == '\r' || c == K_KENTER if (c == '\n' || c == '\r' || c == K_KENTER || c == ESC || c == Ctrl_C)
|| c == ESC || c == Ctrl_C))
trigger_cmd_autocmd(cmdline_type, EVENT_CMDLINELEAVEPRE); trigger_cmd_autocmd(cmdline_type, EVENT_CMDLINELEAVEPRE);
// The wildmenu is cleared if the pressed key is not used for // The wildmenu is cleared if the pressed key is not used for

View File

@ -2038,6 +2038,12 @@ func Test_Cmdline_Trigger()
call assert_equal('', g:log) call assert_equal('', g:log)
call feedkeys(":echo hello", "tx") call feedkeys(":echo hello", "tx")
call assert_equal('CmdlineLeavePre', g:log) 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! bw!
endfunc endfunc

View File

@ -704,6 +704,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1331,
/**/ /**/
1330, 1330,
/**/ /**/