Fixed memory leak.
This commit is contained in:
parent
8b4c66e144
commit
0d5803047b
7
bb.c
7
bb.c
@ -951,10 +951,6 @@ void restore_term(const struct termios *term)
|
|||||||
*/
|
*/
|
||||||
int run_script(bb_t *bb, const char *cmd)
|
int run_script(bb_t *bb, const char *cmd)
|
||||||
{
|
{
|
||||||
char *fullcmd = calloc(strlen(cmd) + strlen(bbcmdfn) + 1, sizeof(char));
|
|
||||||
strcpy(fullcmd, bbcmdfn);
|
|
||||||
strcat(fullcmd, cmd);
|
|
||||||
|
|
||||||
proc_t *proc = memcheck(calloc(1, sizeof(proc_t)));
|
proc_t *proc = memcheck(calloc(1, sizeof(proc_t)));
|
||||||
signal(SIGTTOU, SIG_IGN);
|
signal(SIGTTOU, SIG_IGN);
|
||||||
if ((proc->pid = fork()) == 0) {
|
if ((proc->pid = fork()) == 0) {
|
||||||
@ -968,6 +964,9 @@ int run_script(bb_t *bb, const char *cmd)
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
args[i++] = SH;
|
args[i++] = SH;
|
||||||
args[i++] = "-c";
|
args[i++] = "-c";
|
||||||
|
char *fullcmd = calloc(strlen(cmd) + strlen(bbcmdfn) + 1, sizeof(char));
|
||||||
|
strcpy(fullcmd, bbcmdfn);
|
||||||
|
strcat(fullcmd, cmd);
|
||||||
args[i++] = fullcmd;
|
args[i++] = fullcmd;
|
||||||
args[i++] = "--"; // ensure files like "-i" are not interpreted as flags for sh
|
args[i++] = "--"; // ensure files like "-i" are not interpreted as flags for sh
|
||||||
// bb->selected is in most-recent order, so populate args in reverse to make sure
|
// bb->selected is in most-recent order, so populate args in reverse to make sure
|
||||||
|
Loading…
Reference in New Issue
Block a user