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

Re: [PATCH] builtin/: add UNLEAKs

From
Jeff King <peff@peff.net>
Date
Oct 2, 2017, 06:25 UTC
Message-ID
<20171002062528.naa5hrqoao5sifs3@sigill.intra.peff.net>
In-Reply-To
<20171001174208.1693753-1-martin.agren@gmail.com>
On Sun, Oct 01, 2017 at 07:42:08PM +0200, Martin Ågren wrote:
> Add some UNLEAKs where we are about to return from `cmd_*`. UNLEAK the
> variables in the same order as we've declared them. While addressing
> `msg` in builtin/tag.c, convert the existing `strbuf_release()` calls as
> well.
It might have raised Junio's eyebrows less to say something like:
   ...convert the existing strbuf_release() calls as well (they're not
   wrong, but they also accomplish nothing and create an inconsistency
   with the UNLEAKed variables).
That aside, the patch looks good.
Show 12 quoted lines
> diff --git a/builtin/checkout.c b/builtin/checkout.c
> index 3345a0d16..2daa4412a 100644
> --- a/builtin/checkout.c
> +++ b/builtin/checkout.c
> @@ -1298,6 +1298,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
>  		strbuf_release(&buf);
>  	}
>  
> +	UNLEAK(opts);
>  	if (opts.patch_mode || opts.pathspec.nr)
>  		return checkout_paths(&opts, new.name);
>  	else

Seeing hunks like this makes me happy with the UNLEAK() solution. It would have been a real pain to do this via actual freeing.

-Peff
Previous: Junio C HamanoNext: Martin Ågren
Message 3 of 5 in “builtin/: add UNLEAKs”
  1. builtin/: add UNLEAKsMartin Ågren, Oct 1, 2017
  2. Junio C HamanoOct 2, 2017
  3. Jeff KingOct 2, 2017
  4. Martin ÅgrenOct 2, 2017
  5. Junio C HamanoOct 3, 2017

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.