To: vim_dev@googlegroups.com Subject: Patch 9.0.0820 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ [turns out the script I was using to create the git commit had a problem, should be fixed now, but previous commits still need fixing] Patch 9.0.0820 Problem: Memory leak with empty shell command. Solution: Free the empty string. Files: src/ex_cmds.c *** ../vim-9.0.0818/src/ex_cmds.c 2022-10-22 07:54:22.951580569 +0100 --- src/ex_cmds.c 2022-10-29 20:43:49.437483416 +0100 *************** *** 929,936 **** STRCAT(t, newcmd); if (ins_prevcmd) STRCAT(t, prevcmd); - else - vim_free(t); p = t + STRLEN(t); STRCAT(t, trailarg); vim_free(newcmd); --- 929,934 ---- *************** *** 959,970 **** } } while (trailarg != NULL); ! // Don't clear "prevcmd" if there is no command to run. if (STRLEN(newcmd) > 0) { vim_free(prevcmd); prevcmd = newcmd; } if (bangredo) // put cmd in redo buffer for ! command { --- 957,971 ---- } } while (trailarg != NULL); ! // 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 { *************** *** 988,993 **** --- 989,996 ---- */ if (*p_shq != NUL) { + if (free_newcmd) + vim_free(newcmd); newcmd = alloc(STRLEN(prevcmd) + 2 * STRLEN(p_shq) + 1); if (newcmd == NULL) return; *** ../vim-9.0.0818/src/version.c 2022-10-22 10:06:38.428322861 +0100 --- src/version.c 2022-10-29 21:15:33.523433390 +0100 *************** *** 697,698 **** --- 697,700 ---- { /* Add new patch number below this line */ + /**/ + 820, /**/ -- BEDEVERE: And what do you burn, apart from witches? FOURTH VILLAGER: ... Wood? BEDEVERE: So why do witches burn? SECOND VILLAGER: (pianissimo) ... Because they're made of wood...? "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///