]> granicus.if.org Git - vim/commitdiff
patch 9.0.0820: memory leak with empty shell command v9.0.0820
authorBram Moolenaar <Bram@vim.org>
Sat, 29 Oct 2022 20:53:08 +0000 (21:53 +0100)
committerBram Moolenaar <Bram@vim.org>
Sat, 29 Oct 2022 20:53:08 +0000 (21:53 +0100)
Problem:    Memory leak with empty shell command.
Solution:   Free the empty string.

src/ex_cmds.c
src/version.c

index 44333d514ce0898a97f1d1797308373fc0a3a8f1..7bb7aa0380208fe163f4433b8d3668c7e7c30c44 100644 (file)
@@ -957,12 +957,15 @@ do_bang(
        }
     } while (trailarg != NULL);
 
-    // Don't clear "prevcmd" if there is no command to run.
+    // Only set "prevcmd" if there is a command to run, otherwise keep te one
+    // we have.
     if (STRLEN(newcmd) > 0)
     {
        vim_free(prevcmd);
        prevcmd = newcmd;
     }
+    else
+       free_newcmd = TRUE;
 
     if (bangredo)          // put cmd in redo buffer for ! command
     {
@@ -986,6 +989,8 @@ do_bang(
      */
     if (*p_shq != NUL)
     {
+       if (free_newcmd)
+           vim_free(newcmd);
        newcmd = alloc(STRLEN(prevcmd) + 2 * STRLEN(p_shq) + 1);
        if (newcmd == NULL)
            return;
index f9a00d632e6c142d18329229d3f36848a1a6bac7..2d2ae6aaee04f784a2c061ab4bcdd8402bd3ea12 100644 (file)
@@ -695,6 +695,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    820,
 /**/
     819,
 /**/