git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Rubén Justo" <rjusto@gmail.com>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Cc: git@vger.kernel.org, "Martin Ågren" <martin.agren@gmail.com>
Subject: Re: [PATCH] ref-filter.c: fix a leak in get_head_description
Date: Mon, 26 Sep 2022 21:13:45 +0200	[thread overview]
Message-ID: <8288e9e7-dbea-a5de-c05e-5a22a6a853f6@gmail.com> (raw)
In-Reply-To: <220926.86bkr24kjw.gmgdl@evledraar.gmail.com>

On 26/9/22 10:14, Ævar Arnfjörð Bjarmason wrote:
> 
> Thanks, this looks good to me. FWIW I have a local (still unsubmitted)
> series of leak fixes across the tree which fixed this leak, that commit
> is presented below as a "I've already been running with this for a
> while" data point.

That call in die_if_some_operation_in_progress is a good addition to this fix.
I haven't found a happy path that leaks there yet, but it is calling for it
anyway.  And the commit message looks good to me too.  So you can add to that
patch, if you want:

Reviewed-by: Rubén Justo <rjusto@gmail.com>


Thanks Martin for your review!

Un saludo.

> 
> Thanks!
> 
> -- >8 --
> Subject: [PATCH] wt-status API users: use wt_status_state_free_buffers(), fix
>  leaks
> 
> Fix a memory that was accidentally introduced in ref-filter.c in
> 2708ce62d21 (branch: sort detached HEAD based on a flag, 2021-01-07),
> and one that's been present in builtin/checkout.c since
> c45f0f525de (switch: reject if some operation is in progress,
> 2019-03-29).
> 
> In both cases we should be using the wt_status_state_free_buffers()
> API introduced in 962dd7ebc3e (wt-status: introduce
> wt_status_state_free_buffers(), 2020-09-27).
> 
> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
> ---
>  builtin/checkout.c | 2 ++
>  ref-filter.c       | 2 ++
>  2 files changed, 4 insertions(+)
> 
> diff --git a/builtin/checkout.c b/builtin/checkout.c
> index 54373424403..549c3d17a1a 100644
> --- a/builtin/checkout.c
> +++ b/builtin/checkout.c
> @@ -1469,6 +1469,8 @@ static void die_if_some_operation_in_progress(void)
>  		      "or \"git worktree add\"."));
>  	if (state.bisect_in_progress)
>  		warning(_("you are switching branch while bisecting"));
> +
> +	wt_status_state_free_buffers(&state);
>  }
>  
>  static int checkout_branch(struct checkout_opts *opts,
> diff --git a/ref-filter.c b/ref-filter.c
> index 45908d4bdfc..81278ec3cf7 100644
> --- a/ref-filter.c
> +++ b/ref-filter.c
> @@ -1722,6 +1722,8 @@ char *get_head_description(void)
>  	} else
>  		strbuf_addstr(&desc, _("(no branch)"));
>  
> +	wt_status_state_free_buffers(&state);
> +
>  	return strbuf_detach(&desc, NULL);
>  }
> 

  reply	other threads:[~2022-09-26 19:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-24 22:53 [PATCH] ref-filter.c: fix a leak in get_head_description Rubén Justo
2022-09-26  6:59 ` Martin Ågren
2022-09-26 19:12   ` Junio C Hamano
2022-09-27  5:59     ` Martin Ågren
2022-09-26  8:14 ` Ævar Arnfjörð Bjarmason
2022-09-26 19:13   ` Rubén Justo [this message]
2022-10-08  0:35 ` [PATCH v2] wt-status: using of wt_status_state_free_buffers Rubén Justo

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=8288e9e7-dbea-a5de-c05e-5a22a6a853f6@gmail.com \
    --to=rjusto@gmail.com \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=martin.agren@gmail.com \
    /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).