From owner-freebsd-hackers@FreeBSD.ORG Mon Mar 14 20:45:03 2005 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 614BD16A4CE for ; Mon, 14 Mar 2005 20:45:03 +0000 (GMT) Received: from vsmtp3.tin.it (vsmtp3alice.tin.it [212.216.176.143]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9203A43D1D for ; Mon, 14 Mar 2005 20:45:02 +0000 (GMT) (envelope-from molter@tin.it) Received: from gattaccio.codalunga (82.122.114.246) by vsmtp3.tin.it (7.0.027) (authenticated as molter@tin.it) id 4232AB90000F2C9F for freebsd-hackers@freebsd.org; Mon, 14 Mar 2005 21:45:00 +0100 Received: by gattaccio.codalunga (Postfix, from userid 1001) id 6F54DC17F; Mon, 14 Mar 2005 21:43:52 +0100 (CET) Date: Mon, 14 Mar 2005 21:43:52 +0100 From: Marco Molteni To: freebsd-hackers@freebsd.org Message-Id: <20050314214352.02af2827.molter@tin.it> In-Reply-To: References: X-Mailer: Sylpheed version 1.0.0beta1 (GTK+ 1.2.10; i386-portbld-freebsd6.0) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: memory leak in inflate.c X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Mar 2005 20:45:03 -0000 On Mon, 14 Mar 2005 wrote: > Hi, I am trying to debug a memory leak in executing gzipped binaries > when the parameter list is too long. The function in question is > inflate_dynamic(). > > /* decompress until an end-of-block code */ > if (inflate_codes(glbl, tl, td, bl, bd)) > return 1; > > /* free the decoding tables, return */ > huft_free(glbl, tl); > huft_free(glbl, td); > return 0; > > > Should this be re-written as: > > i = inflate_codes(glbl, tl, td, bl, bd) ? 1 : 0; > > /* free the decoding tables, return */ > huft_free(glbl, tl); > huft_free(glbl, td); > > return (i); > > so that the Huffman tables are always freed. _If_ I remember correctly, if inflate_dynamic() returns a non-zero code it means that the decompression failed and the program itself quits right away, no memory leak. Or am I missing something? marco -- Very graphic, classical but efficient.