mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:9.0.0820: memory leak with empty shell command
Problem: Memory leak with empty shell command.
Solution: Free the empty string.
03d6e6f42b
Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
parent
a1e0f6c07f
commit
2a94dcf0c5
@ -1012,10 +1012,13 @@ void do_bang(int addr_count, exarg_T *eap, bool forceit, bool do_in, bool do_out
|
|||||||
}
|
}
|
||||||
} while (trailarg != NULL);
|
} 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) {
|
if (strlen(newcmd) > 0) {
|
||||||
xfree(prevcmd);
|
xfree(prevcmd);
|
||||||
prevcmd = newcmd;
|
prevcmd = newcmd;
|
||||||
|
} else {
|
||||||
|
free_newcmd = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bangredo) { // put cmd in redo buffer for ! command
|
if (bangredo) { // put cmd in redo buffer for ! command
|
||||||
@ -1031,6 +1034,9 @@ void do_bang(int addr_count, exarg_T *eap, bool forceit, bool do_in, bool do_out
|
|||||||
}
|
}
|
||||||
// Add quotes around the command, for shells that need them.
|
// Add quotes around the command, for shells that need them.
|
||||||
if (*p_shq != NUL) {
|
if (*p_shq != NUL) {
|
||||||
|
if (free_newcmd) {
|
||||||
|
xfree(newcmd);
|
||||||
|
}
|
||||||
newcmd = xmalloc(strlen(prevcmd) + 2 * strlen(p_shq) + 1);
|
newcmd = xmalloc(strlen(prevcmd) + 2 * strlen(p_shq) + 1);
|
||||||
STRCPY(newcmd, p_shq);
|
STRCPY(newcmd, p_shq);
|
||||||
STRCAT(newcmd, prevcmd);
|
STRCAT(newcmd, prevcmd);
|
||||||
|
Loading…
Reference in New Issue
Block a user