Re: [PATCH 05/15] log: report errno on failure to fopen() a file
- From
Jeff King <peff@peff.net>
- Date
- Apr 21, 2017, 06:33 UTC
- Message-ID
- <20170421063324.uumqm4shxunyoii4@sigill.intra.peff.net>
- In-Reply-To
- <20170420112609.26089-6-pclouds@gmail.com>
On Thu, Apr 20, 2017 at 06:25:59PM +0700, Nguyễn Thái Ngọc Duy wrote:
Show 19 quoted lines
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
> builtin/log.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/builtin/log.c b/builtin/log.c
> index b3b10cc1ed..26d6a3cf14 100644
> --- a/builtin/log.c
> +++ b/builtin/log.c
> @@ -858,7 +858,8 @@ static int open_next_file(struct commit *commit, const char *subject,
> printf("%s\n", filename.buf + outdir_offset);
>
> if ((rev->diffopt.file = fopen(filename.buf, "w")) == NULL)
> - return error(_("Cannot open patch file %s"), filename.buf);
> + return error_errno(_("Cannot open patch file %s"),
> + filename.buf);
>
> strbuf_release(&filename);
> return 0;Not a new problem with your patch, but just looking at the context it seems clear that "filename" is leaked in the error case.
-Peff