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: 389172 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id A2EDF140095 for ; Mon, 15 Sep 2014 11:19:49 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:cc:subject:message-id:references :mime-version:content-type:in-reply-to; q=dns; s=default; b=iPua +StAu83ya3SpzdAzun/lCpmZJIThDDuGZKF1zdEMK6MuZi00GN5RsOgVMyeYVsmA WzFjyn0wz8KnqVn1CqofY581fuo4VmXe1mcFvB0xD1r5P+E3zWIcQOOhzWA9wNDy oLy7i5YoKSjsUgX/VLAgduvjnwgusRTnVEWWOBQ= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:cc:subject:message-id:references :mime-version:content-type:in-reply-to; s=default; bh=au7L10p3Sq unIrOVPecI3roDvz4=; b=ehPbSAp7mglbQXHd/l4/SqkNfbTBEi6O1cZsCZMc2b kq7bnEJNIhLFi8ErZ6QV/J4xilMGFZQ0HAdSstWar+1J2CMDFp6cYmWhvfOP8PSP gUyYzVrCpcQxIwgA6ScfFT+ChpoK0TUP0vv6BG368rROdeVWngASFkDeEN7p5tT8 E= 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);