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

Re: [PATCH 1/3] merge-recursive: fix memory leak

From
Jeff King <peff@peff.net>
Date
Aug 29, 2017, 08:12 UTC
Message-ID
<20170829081203.uwt6yfve5uatbhch@sigill.intra.peff.net>
In-Reply-To
<20170828202829.3056-2-kewillf@microsoft.com>
On Mon, Aug 28, 2017 at 02:28:27PM -0600, Kevin Willford wrote:
Show 6 quoted lines
> 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, ...);
  string_clear(re_merge);
  ... other cleanup ...
  if (clean < 0)
	return clean;

without having to resort to a goto. But certainly I don't mind this much more minimal change, which fixes the actual functionality problem.

-Peff
Previous: Ben PeartNext: Kevin Willford
Message 4 of 15 in “merge-recursive: replace string_list with hashmap”
  1. 0/3 merge-recursive: replace string_list with hashmapKevin Willford, Aug 28, 2017
  2. 1/3 merge-recursive: fix memory leakKevin Willford, Aug 28, 2017
  3. Ben PeartAug 28, 2017
  4. Jeff KingAug 29, 2017
  5. 2/3 merge-recursive: remove return value from get_files_dirsKevin Willford, Aug 28, 2017
  6. Ben PeartAug 28, 2017
  7. Jeff KingAug 29, 2017
  8. Jeff KingAug 29, 2017
  9. Kevin WillfordAug 29, 2017
  10. Jeff KingAug 29, 2017
  11. Stefan BellerAug 31, 2017
  12. 3/3 merge-recursive: change current file dir string_lists to hashmapKevin Willford, Aug 28, 2017
  13. Ben PeartAug 28, 2017
  14. Jeff KingAug 29, 2017
  15. Junio C HamanoSep 6, 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.