]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1573: Memory leak when pressing Ctrl-D in cmdline mode v9.1.1573
authorzeertzjq <zeertzjq@outlook.com>
Sun, 20 Jul 2025 14:50:01 +0000 (16:50 +0200)
committerChristian Brabandt <cb@256bit.org>
Sun, 20 Jul 2025 14:50:01 +0000 (16:50 +0200)
Problem:  Memory leak when pressing Ctrl-D in cmdline mode
          (after 9.1.1571).
Solution: Free prev_cmdbuff before assigning to it.
          (zeertzjq).

Existing tests already cover this. This change fixes the CI failure.

closes: #17807

Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/ex_getln.c
src/version.c

index 47187aa92abd08eca8a8aa274efcc398d4ad3d7e..5ee94d2197dfee1abb914a7e0f70d7150741aba0 100644 (file)
@@ -1822,6 +1822,8 @@ getcmdline_int(
        int end_wildmenu;
        int prev_cmdpos = ccline.cmdpos;
 
+       VIM_CLEAR(prev_cmdbuff);
+
        redir_off = TRUE;       // Don't redirect the typed command.
                                // Repeated, because a ":redir" inside
                                // completion may switch it on.
@@ -2574,10 +2576,7 @@ cmdline_not_changed:
 
 #ifdef FEAT_SEARCH_EXTRA
        if (!is_state.incsearch_postponed)
-       {
-           VIM_CLEAR(prev_cmdbuff);
            continue;
-       }
 #endif
 
 cmdline_changed:
@@ -2595,8 +2594,6 @@ cmdline_changed:
                            ccline.cmdbuff, prev_cmdpos) != 0)))
            trigger_cmd_autocmd(cmdline_type, EVENT_CMDLINECHANGED);
 
-       VIM_CLEAR(prev_cmdbuff);
-
        // Trigger CursorMovedC autocommands.
        if (ccline.cmdpos != prev_cmdpos)
            trigger_cmd_autocmd(cmdline_type, EVENT_CURSORMOVEDC);
index b35dac24278bdf5ea0571d23f2bdf50d9dfa6617..251b4decb0e6f9cf2b04441973b032c27ed51f05 100644 (file)
@@ -719,6 +719,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1573,
 /**/
     1572,
 /**/