Re: [PATCH 1/3] merge-recursive: fix memory leak
- Date: Tue, 29 Aug 2017 04:12:03 -0400
- From: Jeff King <peff@xxxxxxxx>
- Subject: Re: [PATCH 1/3] merge-recursive: fix memory leak
On Mon, Aug 28, 2017 at 02:28:27PM -0600, Kevin Willford wrote:
> In merge_trees if process_renames or process_entry returns less
> than zero, the method will just return and not free re_merge,
> re_head, or entries.
> This change cleans up the allocated variables before returning
> to the caller.
Good catch. I suspect this function could stand to be refactored a bit.
For instance, pulling those inner bits of the conditional into a helper
would let us do:
re_merge = get_renames(...);
... other setup ...
clean = our_new_helper(re_merge, ...);
... other cleanup ...
if (clean < 0)
without having to resort to a goto. But certainly I don't mind this much
more minimal change, which fixes the actual functionality problem.