[PATCH] binutils/windres.c: Fix memory leak issue for xmalloc and free 'n'

Chen Gang gang.chen.5i5j@gmail.com
Wed Nov 26 20:57:00 GMT 2014


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



More information about the Binutils mailing list