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

Re: [PATCH] maintenance: fix two memory leaks

From
Junio C Hamano <gitster@pobox.com>
Date
May 10, 2021, 06:34 UTC
Message-ID
<xmqqpmxzqeqd.fsf@gitster.g>
In-Reply-To
<20210509221613.474887-1-lenaic@lhuard.fr>
Lénaïc Huard <lenaic@lhuard.fr> writes:
> Fixes two memory leaks when running `git maintenance start` or `git
> maintenance stop` in `update_background_schedule`:

Thanks, both places look correct, but I have one minor "hmph" comment.

Show 12 quoted lines
> diff --git a/builtin/gc.c b/builtin/gc.c
> index ef7226d7bc..2574068ae2 100644
> --- a/builtin/gc.c
> +++ b/builtin/gc.c
> @@ -1947,6 +1947,7 @@ static int crontab_update_schedule(int run_maintenance, int fd, const char *cmd)
>  		fprintf(cron_in, "\n%s\n", END_LINE);
>  	}
>  
> +	strbuf_release(&line);
>  	fflush(cron_in);
>  	fclose(cron_in);
>  	close(crontab_edit.in);

This is somewhat a curious placement---the loop that iterates over the cron_list FILE with "while (!strbuf_getline_lf(&line, cron_list)" is the only place the list strbuf is used, and I wonder if it makes more sense to do this immediately after the loop.

Show 8 quoted lines
> @@ -1999,6 +2000,7 @@ static int update_background_schedule(int enable)
>  		die("unknown background scheduler: %s", scheduler);
>  
>  	rollback_lock_file(&lk);
> +	free(lock_path);
>  	free(testing);
>  	return result;
>  }
This one looks quite natural.
Previous: Lénaïc HuardNext: lilinchao@oschina.cn
Message 2 of 9 in “maintenance: fix two memory leaks”
  1. maintenance: fix two memory leaksLénaïc Huard, May 9, 2021
  2. Junio C HamanoMay 10, 2021
  3. lilinchao@oschina.cnMay 10, 2021
  4. Junio C HamanoMay 10, 2021
  5. 0/1 maintenance: fix two memory leaksLénaïc Huard, May 10, 2021
  6. 1/1 maintenance: fix two memory leaksLénaïc Huard, May 10, 2021
  7. Derrick StoleeMay 11, 2021
  8. Junio C HamanoMay 11, 2021
  9. lilinchao@oschina.cnMay 10, 2021

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.