From patchwork Mon Sep 15 01:19:24 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 2839 Received: (qmail 7814 invoked by alias); 15 Sep 2014 01:19:43 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 7797 invoked by uid 89); 15 Sep 2014 01:19:39 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.7 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Date: Mon, 15 Sep 2014 06:49:24 +0530 From: Siddhesh Poyarekar To: Allan McRae Cc: Tim Lammens , libc-alpha@sourceware.org Subject: Re: [PATCH] memory leak in libio/wfileops.c do_ftell_wide [BZ #17370] Message-ID: <20140915011924.GB6586@spoyarek.pnq.redhat.com> References: <20140910230520.GC29810@spoyarek.pnq.redhat.com> <5413DA9B.8050001@archlinux.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <5413DA9B.8050001@archlinux.org> User-Agent: Mutt/1.5.22.1-rc1 (2013-10-16) 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 [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);