From: Junio C Hamano <gitster@pobox.com> To: "Lénaïc Huard" <lenaic@lhuard.fr> Cc: git@vger.kernel.org, Derrick Stolee <dstolee@microsoft.com>, Eric Sunshine <sunshine@sunshineco.com> Subject: Re: [PATCH] maintenance: fix two memory leaks Date: Mon, 10 May 2021 15:34:18 +0900 [thread overview] Message-ID: <xmqqpmxzqeqd.fsf@gitster.g> (raw) In-Reply-To: <20210509221613.474887-1-lenaic@lhuard.fr> (=?utf-8?B?Ikw=?= =?utf-8?B?w6luYcOvYw==?= Huard"'s message of "Mon, 10 May 2021 00:16:13 +0200") 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. > 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. > @@ -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.
next prev parent reply other threads:[~2021-05-10 6:34 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-05-09 22:16 Lénaïc Huard 2021-05-10 6:34 ` Junio C Hamano [this message] 2021-05-10 6:38 ` lilinchao 2021-05-10 7:11 ` Junio C Hamano [not found] ` <0c04f7c2b15f11eb82baa4badb2c2b1178978@pobox.com> 2021-05-10 7:50 ` lilinchao 2021-05-10 19:59 ` [PATCH v2 0/1] " Lénaïc Huard 2021-05-10 19:59 ` [PATCH v2 1/1] " Lénaïc Huard 2021-05-11 15:13 ` Derrick Stolee 2021-05-11 3:29 ` [PATCH v2 0/1] " Junio C Hamano
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=xmqqpmxzqeqd.fsf@gitster.g \ --to=gitster@pobox.com \ --cc=dstolee@microsoft.com \ --cc=git@vger.kernel.org \ --cc=lenaic@lhuard.fr \ --cc=sunshine@sunshineco.com \ --subject='Re: [PATCH] maintenance: fix two memory leaks' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).