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

Re: [PATCH 3/5] check-ref-format: Abolish leak of collapsed refname

From
Michael Haggerty <mhagger@alum.mit.edu>
Date
Dec 19, 2016, 11:09 UTC
Message-ID
<71960ab9-c42f-2db6-5359-58afb5a2a8fb@alum.mit.edu>
In-Reply-To
<20161104191358.28812-4-ijackson@chiark.greenend.org.uk>
On 11/04/2016 08:13 PM, Ian Jackson wrote:
Show 18 quoted lines
> collapse_slashes always returns a value from xmallocz.
> 
> Right now this leak is not very interesting, since we only call
> check_one_ref_format once.
> 
> Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
> ---
>  builtin/check-ref-format.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/builtin/check-ref-format.c b/builtin/check-ref-format.c
> index f12c19c..020ebe8 100644
> --- a/builtin/check-ref-format.c
> +++ b/builtin/check-ref-format.c
> @@ -63,8 +63,10 @@ static int check_one_ref_format(const char *refname)
>  		: check_refname_format(refname, flags);
>  	if (got)
>  		return 1;

If the function returns via the line above, then the memory will still be leaked.

Show 9 quoted lines
> -	if (normalize)
> +	if (normalize) {
>  		printf("%s\n", refname);
> +		free((void*)refname);
> +	}
>  }
>  
>  int cmd_check_ref_format(int argc, const char **argv, const char *prefix)
> 
Michael
Previous: Ian JacksonNext: Ian Jackson
Message 3 of 18 in “git check-ref-format --stdin --report-errors”
  1. 0/5 git check-ref-format --stdin --report-errorsIan Jackson, Nov 4, 2016
  2. 3/5 check-ref-format: Abolish leak of collapsed refnameIan Jackson, Nov 4, 2016
  3. Michael HaggertyDec 19, 2016
  4. 1/5 check-ref-format: Refactor out check_one_ref_formatIan Jackson, Nov 4, 2016
  5. Michael HaggertyDec 19, 2016
  6. Ian JacksonDec 19, 2016
  7. Michael HaggertyDec 20, 2016
  8. 2/5 check-ref-format: Refactor to make --branch code more commonIan Jackson, Nov 4, 2016
  9. Michael HaggertyDec 19, 2016
  10. Ian JacksonDec 19, 2016
  11. 5/5 check-ref-format: New --stdin optionIan Jackson, Nov 4, 2016
  12. Michael HaggertyDec 19, 2016
  13. Michael HaggertyDec 19, 2016
  14. 4/5 check-ref-format: New --report-errors optionIan Jackson, Nov 4, 2016
  15. Michael HaggertyDec 19, 2016
  16. Ian JacksonDec 19, 2016
  17. Junio C HamanoDec 19, 2016
  18. Michael HaggertyDec 20, 2016

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.