Re: [PATCH] builtin/am: fix memory leak in `split_mail_stgit_series`

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

 



"Lidong Yan via GitGitGadget" <gitgitgadget@xxxxxxxxx> writes:

> From: Lidong Yan <502024330056@xxxxxxxxxxxxxxxx>
>
> In builtin/am.c:split_mail_stgit_series, if `fopen` failed,
> `series_dir_buf` allocated by `xstrdup` will leak. Add `free` in
> `!fp` if branch will prevent the leak.
>
> diff --git a/builtin/am.c b/builtin/am.c
> index 4afb519830f..e32a3b4c973 100644
> --- a/builtin/am.c
> +++ b/builtin/am.c
> @@ -850,8 +850,10 @@ static int split_mail_stgit_series(struct am_state *state, const char **paths,
>  	series_dir = dirname(series_dir_buf);
>  
>  	fp = fopen(*paths, "r");
> -	if (!fp)
> +	if (!fp) {
> +		free(series_dir_buf);
>  		return error_errno(_("could not open '%s' for reading"), *paths);
> +	}
>  
>  	while (!strbuf_getline_lf(&sb, fp)) {
>  		if (*sb.buf == '#')
>
> base-commit: 6f84262c44a89851c3ae5a6e4c1a9d06b2068d75

Obviously correct; will queue.  Thanks.




[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