This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] memory leak in libio/wfileops.c do_ftell_wide [BZ #17370]
- From: Allan McRae <allan at archlinux dot org>
- To: Siddhesh Poyarekar <siddhesh at redhat dot com>
- Cc: Tim Lammens <tim dot lammens at gmail dot com>, libc-alpha at sourceware dot org
- Date: Mon, 15 Sep 2014 22:00:13 +1000
- Subject: Re: [PATCH] memory leak in libio/wfileops.c do_ftell_wide [BZ #17370]
- Authentication-results: sourceware.org; auth=none
- References: <CAC+sh-dSpNLcdwkJA_J+XPFCxmMibgcAbof71o2eQ2pK5O2b-A at mail dot gmail dot com> <20140910230520 dot GC29810 at spoyarek dot pnq dot redhat dot com> <5413DA9B dot 8050001 at archlinux dot org> <20140915011924 dot GB6586 at spoyarek dot pnq dot redhat dot com>
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);
>