aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2020-01-12 23:19:03 -0800
committerBruce Hill <bruce@bruce-hill.com>2020-01-12 23:19:03 -0800
commit0d5803047b9bfbbe9bc3892be50140509c611d1e (patch)
tree395719f629f85be3d35a2f22b05d6accec70cc7f
parent8b4c66e144ed68d947f9a8b36468c1fa20873dc5 (diff)
Fixed memory leak.
-rw-r--r--bb.c7
-rw-r--r--bb.h2
2 files changed, 4 insertions, 5 deletions
diff --git a/bb.c b/bb.c
index 4acdafa..d8d3c13 100644
--- a/bb.c
+++ b/bb.c
@@ -951,10 +951,6 @@ void restore_term(const struct termios *term)
*/
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)));
signal(SIGTTOU, SIG_IGN);
if ((proc->pid = fork()) == 0) {
@@ -968,6 +964,9 @@ int run_script(bb_t *bb, const char *cmd)
int i = 0;
args[i++] = SH;
args[i++] = "-c";
+ char *fullcmd = calloc(strlen(cmd) + strlen(bbcmdfn) + 1, sizeof(char));
+ strcpy(fullcmd, bbcmdfn);
+ strcat(fullcmd, cmd);
args[i++] = fullcmd;
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
diff --git a/bb.h b/bb.h
index 298bc06..e133800 100644
--- a/bb.h
+++ b/bb.h
@@ -25,7 +25,7 @@
#include "bterm.h"
// Macros:
-#define BB_VERSION "0.20.4"
+#define BB_VERSION "0.20.5"
#ifndef PATH_MAX
#define PATH_MAX 4096