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