From: Junio C Hamano <gitster@pobox.com>
To: "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Johannes Schindelin <johannes.schindelin@gmx.de>
Subject: Re: [PATCH 1/2] fsmonitor: fix memory corruption in some corner cases
Date: Wed, 17 Mar 2021 12:19:04 -0700 [thread overview]
Message-ID: <xmqqwnu5twpj.fsf@gitster.g> (raw)
In-Reply-To: <e194809e547eb5bc8e8d1ad09d874ebfde0efe4f.1615995049.git.gitgitgadget@gmail.com> (Johannes Schindelin via GitGitGadget's message of "Wed, 17 Mar 2021 15:30:48 +0000")
"Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
writes:
> --- 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
next prev parent reply other threads:[~2021-03-17 19:20 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-17 15:30 [PATCH 0/2] Fix memory corruption with FSMonitor-enabled unpack_trees() Johannes Schindelin via GitGitGadget
2021-03-17 15:30 ` [PATCH 1/2] fsmonitor: fix memory corruption in some corner cases Johannes Schindelin via GitGitGadget
2021-03-17 19:19 ` Junio C Hamano [this message]
2021-03-17 15:30 ` [PATCH 2/2] fsmonitor: do not forget to release the token in `discard_index()` Johannes Schindelin via GitGitGadget
2021-03-17 20:21 ` [PATCH 0/2] Fix memory corruption with FSMonitor-enabled unpack_trees() Derrick Stolee
2021-03-19 14:49 ` Johannes Schindelin
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=xmqqwnu5twpj.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=johannes.schindelin@gmx.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.