From: Jeff King <peff@peff.net>
To: Toon Claes <toon@iotcl.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] merge: fix leak with merge.defaultToUpstream
Date: Tue, 28 Jul 2026 11:19:59 -0400 [thread overview]
Message-ID: <20260728151959.GC41931@coredump.intra.peff.net> (raw)
In-Reply-To: <20260728-toon-fix-merge-leak-v1-1-d6bd161a3acf@iotcl.com>
On Tue, Jul 28, 2026 at 03:00:04PM +0200, Toon Claes wrote:
> The leak has been present since 93e535a5b7 (merge: merge with the
> default upstream branch without argument, 2011-03-24). Although the leak
> sanitizer was enabled for tests in fc1ddf42af (t: remove
> TEST_PASSES_SANITIZE_LEAK annotations, 2024-11-21), it went unnoticed
> because no test calls `git merge` without arguments, exercising the
> default-to-upstream path. Add such a test in t7600, which fails under
> the leak sanitizer without this fix.
Wow, I'm surprised we didn't cover this case in the test suite.
Increasing coverage is good.
> @@ -1517,8 +1517,10 @@ int cmd_merge(int argc,
> option_commit = 1;
>
> if (!argc) {
> - if (default_to_upstream)
> + if (default_to_upstream) {
> argc = setup_with_upstream(&argv);
> + argv_to_free = argv;
> + }
The fix looks correct to me. This whole argv-juggling is pretty gross
(especially the part below which overwrites argv[0]!). I suspect using a
separate strvec to hold the heads would be cleaner, but it is probably
not worth anybody's time to micro-polish this.
-Peff
next prev parent reply other threads:[~2026-07-28 15:20 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-28 13:00 [PATCH] merge: fix leak with merge.defaultToUpstream Toon Claes
2026-07-28 15:19 ` Jeff King [this message]
2026-07-28 18:12 ` Junio C Hamano
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=20260728151959.GC41931@coredump.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=toon@iotcl.com \
/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