This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] binutils/windres.c: Fix memory leak issue for xmalloc and free 'n'
- From: Chen Gang <gang dot chen dot 5i5j at gmail dot com>
- To: binutils at sourceware dot org, amodra at gmail dot com
- Date: Thu, 27 Nov 2014 04:57:42 +0800
- Subject: Re: [PATCH] binutils/windres.c: Fix memory leak issue for xmalloc and free 'n'
- Authentication-results: sourceware.org; auth=none
- References: <5464BEE0 dot 1060907 at gmail dot com>
Please help check this patch, when you have time.
Thanks.
On 11/13/2014 10:23 PM, Chen Gang wrote:
> After xmalloc 'n', if fopen() fails, need free 'n', or will cause memory
> leak.
>
> 2014-11-13 Chen Gang <gang.chen.5i5j@gmail.com>
>
> * binutiles/windres.c (open_file_search): Fix memory leak issue
> for xmalloc and free 'n'.
> ---
> binutils/windres.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/binutils/windres.c b/binutils/windres.c
> index 7fa90fc..10aa722 100644
> --- a/binutils/windres.c
> +++ b/binutils/windres.c
> @@ -204,6 +204,7 @@ open_file_search (const char *filename, const char *mode, const char *errmsg,
> *real_filename = n;
> return e;
> }
> + free(n);
>
> if (errno != ENOENT)
> break;
>
--
Chen Gang
Open share and attitude like air water and life which God blessed