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