Re: [PATCH] maintenance: fix two memory leaks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Lénaïc Huard <lenaic@xxxxxxxxx> 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.




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux