This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] memory leak in libio/wfileops.c do_ftell_wide [BZ #17370]


On 15/09/14 11:19, Siddhesh Poyarekar wrote:
> On Sat, Sep 13, 2014 at 03:48:11PM +1000, Allan McRae wrote:
>> Do we also need to free this in the error case directly above?
> 
> Ugh, yes, thanks for catching that.  Here's a patch to do that.
> Tested on x86_64.
> 
> Siddhesh
> 

Looks good.

Allan

> 	[BZ #17370]
> 	* libio/wfileops.c (do_ftell_wide): Free OUT on error path.
> 
> diff --git a/libio/wfileops.c b/libio/wfileops.c
> index ebc06e8..c5ec5f7 100644
> --- a/libio/wfileops.c
> +++ b/libio/wfileops.c
> @@ -708,7 +708,10 @@ do_ftell_wide (_IO_FILE *fp)
>  		 sequences must be complete since they are accepted as
>  		 wchar_t; if not, then that is an error.  */
>  	      if (__glibc_unlikely (status != __codecvt_ok))
> -		return WEOF;
> +		{
> +		  free (out);
> +		  return WEOF;
> +		}
>  
>  	      offset += outstop - out;
>  	      free (out);
> 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]