diff options
| author | Junio C Hamano <gitster@pobox.com> | 2025-02-06 14:56:45 -0800 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-02-06 14:56:45 -0800 |
| commit | 5f338eae76ea739954517292b8b057d1b6187926 (patch) | |
| tree | 4a88436f835b7e9ee9a187a517dec48519e12b14 | |
| parent | 9d0e81e2ae3bd7f6d8a655be53c2396d7af3d2b0 (diff) | |
| parent | 087740d65a5d28756ecbe56fc3b10328b52e8d33 (diff) | |
| download | git-5f338eae76ea739954517292b8b057d1b6187926.tar.xz | |
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
| -rw-r--r-- | scalar.c | 4 | ||||
| -rw-r--r-- | unix-socket.c | 4 |
2 files changed, 6 insertions, 2 deletions
@@ -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); diff --git a/unix-socket.c b/unix-socket.c index 483c9c448c..8860203c3f 100644 --- a/unix-socket.c +++ b/unix-socket.c @@ -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)); |
