From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: Eric DeCosta <edecosta@mathworks.com>, git@vger.kernel.org
Subject: Re: What's cooking in git.git (Oct 2022, #03; Mon, 10)
Date: Mon, 10 Oct 2022 22:21:40 -0700 [thread overview]
Message-ID: <xmqqczazx7dn.fsf@gitster.g> (raw)
In-Reply-To: <Y0S7/jA5tNeoQ2Hm@coredump.intra.peff.net> (Jeff King's message of "Mon, 10 Oct 2022 20:42:38 -0400")
Jeff King <peff@peff.net> writes:
> There's a tiny leak in this one. Here's a fix that can go on top.
>
> -- >8 --
> Subject: [PATCH] fsmonitor: fix leak of warning message
>
> The fsm_settings__get_incompatible_msg() function returns an allocated
> string. So we can't pass its result directly to warning(); we must hold
> on to the pointer and free it to avoid a leak.
>
> The leak here is small and fixed size, but Coverity complained, and
> presumably SANITIZE=leaks would eventually.
>
> Signed-off-by: Jeff King <peff@peff.net>
> ---
> fsmonitor.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
Is there anybody else who is reading Coverity reports, I wonder.
This one is a clear positive.
Thanks.
> diff --git a/fsmonitor.c b/fsmonitor.c
> index 540736b39f..08af00c738 100644
> --- a/fsmonitor.c
> +++ b/fsmonitor.c
> @@ -309,8 +309,10 @@ void refresh_fsmonitor(struct index_state *istate)
> enum fsmonitor_reason reason = fsm_settings__get_reason(r);
>
> if (!warn_once && reason > FSMONITOR_REASON_OK) {
> + char *msg = fsm_settings__get_incompatible_msg(r, reason);
> warn_once = 1;
> - warning("%s", fsm_settings__get_incompatible_msg(r, reason));
> + warning("%s", msg);
> + free(msg);
> }
>
> if (fsm_mode <= FSMONITOR_MODE_DISABLED ||
next prev parent reply other threads:[~2022-10-11 5:22 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-10 23:37 What's cooking in git.git (Oct 2022, #03; Mon, 10) Junio C Hamano
2022-10-11 0:42 ` Jeff King
2022-10-11 5:21 ` Junio C Hamano [this message]
2022-10-11 13:08 ` Jeff King
2022-12-20 23:11 ` Johannes Schindelin
2022-12-21 23:14 ` Jeff King
2022-12-22 8:58 ` Ævar Arnfjörð Bjarmason
2022-12-22 17:40 ` Jeff King
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqczazx7dn.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=edecosta@mathworks.com \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).