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

Re: [PATCH 1/2] fsmonitor: fix memory corruption in some corner cases

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 17, 2021, 19:19 UTC
Message-ID
<xmqqwnu5twpj.fsf@gitster.g>
In-Reply-To
<e194809e547eb5bc8e8d1ad09d874ebfde0efe4f.1615995049.git.gitgitgadget@gmail.com>

"Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com> writes:

Show 10 quoted lines
> --- a/unpack-trees.c
> +++ b/unpack-trees.c
> @@ -1544,8 +1544,8 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
>  	o->merge_size = len;
>  	mark_all_ce_unused(o->src_index);
>  
> -	if (o->src_index->fsmonitor_last_update)
> -		o->result.fsmonitor_last_update = o->src_index->fsmonitor_last_update;
> +	o->result.fsmonitor_last_update =
> +		xstrdup_or_null(o->src_index->fsmonitor_last_update);

And this won't happen twice, so there is no need to free what is in the o->result side before assignment. And 2/2 frees it so we do not leak at the end either.

Will queue; thanks.
>  
>  	/*
>  	 * Sparse checkout loop #1: set NEW_SKIP_WORKTREE on existing entries
Previous: Johannes Schindelin via GitGitGadgetNext: Johannes Schindelin via GitGitGadget
Message 3 of 6 in “Fix memory corruption with FSMonitor-enabled unpack_trees()”
  1. 0/2 Fix memory corruption with FSMonitor-enabled unpack_trees()Johannes Schindelin via GitGitGadget, Mar 17, 2021
  2. 1/2 fsmonitor: fix memory corruption in some corner casesJohannes Schindelin via GitGitGadget, Mar 17, 2021
  3. Junio C HamanoMar 17, 2021
  4. 2/2 fsmonitor: do not forget to release the token in `discard_index()`Johannes Schindelin via GitGitGadget, Mar 17, 2021
  5. Derrick StoleeMar 17, 2021
  6. Johannes SchindelinMar 19, 2021

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.