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

Re: [PATCH] object-file: fix leak on conversion failure

From
Derrick Stolee <stolee@gmail.com>
Date
Jun 23, 2024, 16:34 UTC
Message-ID
<1f536f91-1dce-4156-98f2-4059cd5235ff@gmail.com>
In-Reply-To
<20240622043648.M78681@dcvr>
On 6/22/24 12:36 AM, Eric Wong wrote:
> I'm not sure exactly how to trigger the leak, but it seems fairly
> obvious that the `content' buffer should be freed even if
> convert_object_file() fails.  Noticed while working in this area
> on unrelated things.

Definitely a good thing to include, even if it is unlikely to be hit frequently in common scenarios.

Show 7 quoted lines
>   			ret = convert_object_file(&outbuf,
>   						  the_hash_algo, input_algo,
>   						  content, size, type, !do_die);
> +			free(content);
>   			if (ret == -1)
>   				return -1;
> -			free(content);

I looked at the context of this function to see that 'content' was local to the method, so was not "owned" by something outside of the method that might expect to reuse the buffer on failure.

Thanks, -Stolee

Previous: Eric WongNext: Junio C Hamano
Message 2 of 3 in “object-file: fix leak on conversion failure”
  1. object-file: fix leak on conversion failureEric Wong, Jun 22, 2024
  2. Derrick StoleeJun 23, 2024
  3. Junio C HamanoJun 24, 2024

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.