From: "Rubén Justo" <rjusto@gmail.com>
To: Git List <git@vger.kernel.org>
Cc: Jeff King <peff@peff.net>, Junio C Hamano <gitster@pobox.com>
Subject: [PATCH v3 2/5] branch: fix a leak in setup_tracking
Date: Sat, 17 Jun 2023 08:41:08 +0200 [thread overview]
Message-ID: <3d33cd59-d4f3-9112-457f-7d1bfdd08714@gmail.com> (raw)
In-Reply-To: <71b49be1-eeef-2f60-38f1-cfcbe4c8252f@gmail.com>
In bdaf1dfae7 (branch: new autosetupmerge option "simple" for matching
branches, 2022-04-29) a new exit for setup_tracking() missed the
clean-up, producing a leak.
$ git config branch.autoSetupMerge simple
$ git remote add local .
$ git update-ref refs/remotes/local/foo HEAD
$ git branch bar local/foo
Direct leak of 384 byte(s) in 1 object(s) allocated from:
... in xrealloc wrapper.c
... in string_list_append_nodup string-list.c
... in find_tracked_branch branch.c
... in for_each_remote remote.c
... in setup_tracking branch.c
... in create_branch branch.c
... in cmd_branch builtinbranch.c
... in run_builtin git.c
Indirect leak of 24 byte(s) in 1 object(s) allocated from:
... in xrealloc wrapper.c
... in strbuf_grow strbuf.c
... in strbuf_add strbuf.c
... in match_name_with_pattern remote.c
... in query_refspecs remote.c
... in remote_find_tracking remote.c
... in find_tracked_branch branch.c
... in for_each_remote remote.c
... in setup_tracking branch.c
... in create_branch branch.c
... in cmd_branch builtinbranch.c
... in run_builtin git.c
The return introduced in bdaf1dfae7 was to avoid setting up the
tracking, but even in that case it is still necessary to do the
clean-up. Let's do it.
Signed-off-by: Rubén Justo <rjusto@gmail.com>
---
branch.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/branch.c b/branch.c
index 427bde896f..d88f50a48a 100644
--- a/branch.c
+++ b/branch.c
@@ -333,7 +333,7 @@ static void setup_tracking(const char *new_ref, const char *orig_ref,
if (!skip_prefix(tracking.srcs->items[0].string,
"refs/heads/", &tracked_branch) ||
strcmp(tracked_branch, new_ref))
- return;
+ goto cleanup;
}
if (tracking.srcs->nr < 1)
--
2.40.1
next prev parent reply other threads:[~2023-06-17 6:42 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-11 18:29 tests: mark as passing with SANITIZE=leak Rubén Justo
2023-06-11 18:49 ` [PATCH 01/11] rev-parse: fix a leak with --abbrev-ref Rubén Justo
2023-06-12 3:12 ` Jeff King
2023-06-16 22:34 ` Rubén Justo
2023-06-11 18:49 ` [PATCH 02/11] config: fix a leak in git_config_copy_or_rename_section_in_file Rubén Justo
2023-06-12 3:14 ` Jeff King
2023-06-11 18:49 ` [PATCH 03/11] remote: fix a leak in query_matches_negative_refspec Rubén Justo
2023-06-12 3:17 ` Jeff King
2023-06-16 22:37 ` Rubén Justo
2023-06-11 18:49 ` [PATCH 04/11] branch: fix a leak in dwim_and_setup_tracking Rubén Justo
2023-06-12 3:21 ` Jeff King
2023-06-16 22:45 ` Rubén Justo
2023-06-11 18:49 ` [PATCH 05/11] branch: fix a leak in setup_tracking Rubén Justo
2023-06-12 3:26 ` Jeff King
2023-06-16 22:46 ` Rubén Justo
2023-06-11 18:50 ` [PATCH 06/11] branch: fix a leak in cmd_branch Rubén Justo
2023-06-12 3:46 ` Jeff King
2023-06-16 22:50 ` Rubén Justo
2023-06-11 18:50 ` [PATCH 07/11] branch: fix a leak in inherit_tracking Rubén Justo
2023-06-12 3:48 ` Jeff King
2023-06-11 18:50 ` [PATCH 08/11] branch: fix a leak in check_tracking_branch Rubén Justo
2023-06-12 3:55 ` Jeff King
2023-06-11 18:50 ` [PATCH 09/11] branch: fix a leak in setup_tracking Rubén Justo
2023-06-12 3:59 ` Jeff King
2023-06-11 18:50 ` [PATCH 10/11] config: fix a leak in git_config_copy_or_rename_section_in_file Rubén Justo
2023-06-12 4:05 ` Jeff King
2023-06-16 23:04 ` Rubén Justo
2023-06-11 18:50 ` [PATCH 11/11] tests: mark as passing with SANITIZE=leak Rubén Justo
2023-06-11 21:23 ` Rubén Justo
2023-06-12 4:06 ` Jeff King
2023-06-16 23:14 ` Rubén Justo
2023-06-13 19:34 ` Junio C Hamano
2023-06-16 23:27 ` [PATCH v2 0/5] " Rubén Justo
2023-06-16 23:34 ` [PATCH v2 1/5] rev-parse: fix a leak with --abbrev-ref Rubén Justo
2023-06-16 23:34 ` [PATCH v2 2/5] branch: fix a leak in setup_tracking Rubén Justo
2023-06-16 23:34 ` [PATCH v2 3/5] branch: fix a leak in cmd_branch Rubén Justo
2023-06-16 23:34 ` [PATCH v2 4/5] config: fix a leak in git_config_copy_or_rename_section_in_file Rubén Justo
2023-06-16 23:35 ` [PATCH v2 5/5] tests: mark as passing with SANITIZE=leak Rubén Justo
2023-06-16 23:45 ` [PATCH v2 0/5] " Junio C Hamano
2023-06-17 5:48 ` Jeff King
2023-06-17 6:35 ` Rubén Justo
2023-06-17 6:37 ` [PATCH v3 " Rubén Justo
2023-06-17 6:40 ` [PATCH v3 1/5] rev-parse: fix a leak with --abbrev-ref Rubén Justo
2023-06-17 6:41 ` Rubén Justo [this message]
2023-06-17 6:41 ` [PATCH v3 3/5] branch: fix a leak in cmd_branch Rubén Justo
2023-06-17 6:41 ` [PATCH v3 4/5] config: fix a leak in git_config_copy_or_rename_section_in_file Rubén Justo
2023-06-17 6:41 ` [PATCH v3 5/5] tests: mark as passing with SANITIZE=leak Rubén Justo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3d33cd59-d4f3-9112-457f-7d1bfdd08714@gmail.com \
--to=rjusto@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=peff@peff.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).