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

Re: [PATCH 1/5] submodule_move_head: fix leak of struct child_process

From
BWBrandon Williams <bmwill@google.com>
Date
May 1, 2017, 18:06 UTC
Message-ID
<20170501180610.GF39135@google.com>
In-Reply-To
<20170501180058.8063-2-sbeller@google.com>
On 05/01, Stefan Beller wrote:
> While fixing the leak of `cp`, reuse it instead of having to declare
> another struct child_process.
> 
> Signed-off-by: Stefan Beller <sbeller@google.com>

This shouldn't be needed as 'finish_command' does the cleanup for you by calling 'child_prcoess_clear()'.

Show 45 quoted lines
> ---
>  submodule.c | 15 +++++++++------
>  1 file changed, 9 insertions(+), 6 deletions(-)
> 
> diff --git a/submodule.c b/submodule.c
> index d3299e29c0..cd098cf12b 100644
> --- a/submodule.c
> +++ b/submodule.c
> @@ -1466,17 +1466,19 @@ int submodule_move_head(const char *path,
>  		goto out;
>  	}
>  
> +	child_process_clear(&cp);
> +
>  	if (!(flags & SUBMODULE_MOVE_HEAD_DRY_RUN)) {
>  		if (new) {
> -			struct child_process cp1 = CHILD_PROCESS_INIT;
> +			child_process_init(&cp);
>  			/* also set the HEAD accordingly */
> -			cp1.git_cmd = 1;
> -			cp1.no_stdin = 1;
> -			cp1.dir = path;
> +			cp.git_cmd = 1;
> +			cp.no_stdin = 1;
> +			cp.dir = path;
>  
> -			argv_array_pushl(&cp1.args, "update-ref", "HEAD", new, NULL);
> +			argv_array_pushl(&cp.args, "update-ref", "HEAD", new, NULL);
>  
> -			if (run_command(&cp1)) {
> +			if (run_command(&cp)) {
>  				ret = -1;
>  				goto out;
>  			}
> @@ -1492,6 +1494,7 @@ int submodule_move_head(const char *path,
>  		}
>  	}
>  out:
> +	child_process_clear(&cp);
>  	return ret;
>  }
>  
> -- 
> 2.13.0.rc1.1.gbc33f0f778
> 
-- 
Brandon Williams
Previous: Stefan BellerNext: Junio C Hamano
Message 3 of 22 in “Some submodule bugfixes and "reattaching detached HEADs"”
  1. 0/5 Some submodule bugfixes and "reattaching detached HEADs"Stefan Beller, May 1, 2017
  2. 1/5 submodule_move_head: fix leak of struct child_processStefan Beller, May 1, 2017
  3. Brandon WilliamsMay 1, 2017
  4. Junio C HamanoMay 2, 2017
  5. Stefan BellerMay 2, 2017
  6. 3/5 submodule: avoid auto-discovery in new working tree manipulator codeStefan Beller, May 1, 2017
  7. 2/5 submodule_move_head: prepare env for child correctlyStefan Beller, May 1, 2017
  8. Junio C HamanoMay 2, 2017
  9. Stefan BellerMay 2, 2017
  10. 4/5 submodule--helper: reattach-HEADStefan Beller, May 1, 2017
  11. Brandon WilliamsMay 1, 2017
  12. Stefan BellerMay 1, 2017
  13. 5/5 submodule_move_head: reattach submodule HEAD to branch if possible.Stefan Beller, May 1, 2017
  14. Brandon WilliamsMay 1, 2017
  15. Junio C HamanoMay 2, 2017
  16. Stefan BellerMay 2, 2017
  17. Stefan BellerMay 31, 2017
  18. 0/3 Some submodule bugfixesStefan Beller, May 2, 2017
  19. 1/3 submodule_move_head: reuse child_process structure for futher commandsStefan Beller, May 2, 2017
  20. 2/3 submodule: avoid auto-discovery in new working tree manipulator codeStefan Beller, May 2, 2017
  21. 3/3 submodule: properly recurse for read-tree and checkoutStefan Beller, May 2, 2017
  22. Brandon WilliamsMay 2, 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.