Skip to content
Snippets Groups Projects
Commit 5f338eae authored by Junio C Hamano's avatar Junio C Hamano
Browse files

Merge branch 'ps/leakfixes-0129'

A few more leakfixes.

* ps/leakfixes-0129:
  scalar: free result of `remote_default_branch()`
  unix-socket: fix memory leak when chdir(3p) fails
parents 9d0e81e2 087740d6
No related branches found
No related tags found
No related merge requests found
......@@ -409,6 +409,7 @@ void load_builtin_commands(const char *prefix UNUSED,
static int cmd_clone(int argc, const char **argv)
{
const char *branch = NULL;
char *branch_to_free = NULL;
int full_clone = 0, single_branch = 0, show_progress = isatty(2);
int src = 1, tags = 1;
struct option clone_options[] = {
......@@ -490,7 +491,7 @@ static int cmd_clone(int argc, const char **argv)
/* common-main already logs `argv` */
trace2_def_repo(the_repository);
if (!branch && !(branch = remote_default_branch(url))) {
if (!branch && !(branch = branch_to_free = remote_default_branch(url))) {
res = error(_("failed to get default branch for '%s'"), url);
goto cleanup;
}
......@@ -552,6 +553,7 @@ static int cmd_clone(int argc, const char **argv)
res = register_dir();
cleanup:
free(branch_to_free);
free(enlistment);
free(dir);
strbuf_release(&buf);
......
......@@ -65,8 +65,10 @@ static int unix_sockaddr_init(struct sockaddr_un *sa, const char *path,
if (strbuf_getcwd(&cwd))
return -1;
ctx->orig_dir = strbuf_detach(&cwd, NULL);
if (chdir_len(dir, slash - dir) < 0)
if (chdir_len(dir, slash - dir) < 0) {
FREE_AND_NULL(ctx->orig_dir);
return -1;
}
}
memset(sa, 0, sizeof(*sa));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment