git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] merge: fix leak with merge.defaultToUpstream

From
Jeff King <peff@peff.net>
Date
Jul 28, 2026, 15:19 UTC
Message-ID
<20260728151959.GC41931@coredump.intra.peff.net>
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:
Show 7 quoted lines
> 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.

Show 9 quoted lines
> @@ -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
Previous: Toon ClaesNext: Junio C Hamano
Message 2 of 3 in “merge: fix leak with merge.defaultToUpstream”
  1. merge: fix leak with merge.defaultToUpstreamToon Claes, Jul 28, 2026
  2. Jeff KingJul 28, 2026
  3. Junio C HamanoJul 28, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.