On Sun, Jul 20, 2014 at 7:55 PM, Eric Sunshine <sunshine@xxxxxxxxxxxxxx> wrote: > On Sun, Jul 13, 2014 at 12:51 AM, Nguyễn Thái Ngọc Duy > <pclouds@xxxxxxxxx> wrote: >> + >> + junk_pid = getpid(); >> + atexit(remove_junk); >> + sigchain_push_common(remove_junk_on_signal); >> + >> if (mkdir(sb_repo.buf, 0777)) >> die_errno(_("could not create directory of '%s'"), sb_repo.buf); >> + junk_git_dir = sb_repo.buf; > > I've managed to convince myself that, although junk_git_dir becomes a > dangling pointer by the end of prepare_linked_checkout(), it should > never afterward be accessed. Perhaps it would make sense to make this > easier to follow by clearing junk_git_dir when is_junk is cleared? > >> + is_junk = 1; >> >> strbuf_addf(&sb_git, "%s/.git", path); >> if (safe_create_leading_directories_const(sb_git.buf)) >> die_errno(_("could not create leading directories of '%s'"), >> sb_git.buf); >> + junk_work_tree = path; >> >> write_file(sb_git.buf, 1, "gitdir: %s/repos/%s\n", >> real_path(get_git_common_dir()), name); >> @@ -879,7 +917,14 @@ static int prepare_linked_checkout(const struct checkout_opts *opts, >> memset(&cp, 0, sizeof(cp)); >> cp.git_cmd = 1; >> cp.argv = opts->saved_argv; >> - return run_command(&cp); >> + ret = run_command(&cp); >> + if (!ret) >> + is_junk = 0; > > Here: perhaps also set is_junk_dir to NULL since it otherwise is about > to become a dangling pointer. My bad: s/is_junk_dir/junk_git_dir/ -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html