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
This commit is contained in:
Junio C Hamano
2025-02-06 14:56:45 -08:00
2 changed files with 6 additions and 2 deletions

View File

@ -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));