Skip to content

Commit 1aadb47

Browse files
committed
Merge branch 'jk/worktree-check-clean-leakfix'
Leakfix. * jk/worktree-check-clean-leakfix: worktree: fix leak in check_clean_worktree()
2 parents a31677d + 27ed6cc commit 1aadb47

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

builtin/worktree.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,6 @@ static int move_worktree(int ac, const char **av, const char *prefix)
924924
static void check_clean_worktree(struct worktree *wt,
925925
const char *original_path)
926926
{
927-
struct strvec child_env = STRVEC_INIT;
928927
struct child_process cp;
929928
char buf[1];
930929
int ret;
@@ -935,15 +934,14 @@ static void check_clean_worktree(struct worktree *wt,
935934
*/
936935
validate_no_submodules(wt);
937936

938-
strvec_pushf(&child_env, "%s=%s/.git",
937+
child_process_init(&cp);
938+
strvec_pushf(&cp.env_array, "%s=%s/.git",
939939
GIT_DIR_ENVIRONMENT, wt->path);
940-
strvec_pushf(&child_env, "%s=%s",
940+
strvec_pushf(&cp.env_array, "%s=%s",
941941
GIT_WORK_TREE_ENVIRONMENT, wt->path);
942-
memset(&cp, 0, sizeof(cp));
943942
strvec_pushl(&cp.args, "status",
944943
"--porcelain", "--ignore-submodules=none",
945944
NULL);
946-
cp.env = child_env.v;
947945
cp.git_cmd = 1;
948946
cp.dir = wt->path;
949947
cp.out = -1;

0 commit comments

Comments
 (0)