From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gnu.wildebeest.org (wildebeest.demon.nl [212.238.236.112]) by sourceware.org (Postfix) with ESMTPS id 6F830385F02A for ; Fri, 20 Mar 2020 17:10:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 6F830385F02A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=klomp.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mark@klomp.org Received: from tarox.wildebeest.org (tarox.wildebeest.org [172.31.17.39]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id 8638F30447E2; Fri, 20 Mar 2020 18:10:06 +0100 (CET) Received: by tarox.wildebeest.org (Postfix, from userid 1000) id 363A9413CD51; Fri, 20 Mar 2020 18:10:06 +0100 (CET) Message-ID: <146b2fb6815840d6c566a52140ffa62699e66de2.camel@klomp.org> Subject: Re: [PATCH v2] libelf: {de,}compress: ensure zlib resource cleanup From: Mark Wielaard To: Matthias Maennich , elfutils-devel@sourceware.org Cc: kernel-team@android.com Date: Fri, 20 Mar 2020 18:10:06 +0100 In-Reply-To: <20200320111755.67258-1-maennich@google.com> References: <20200315220329.82201-1-maennich@google.com> <20200320111755.67258-1-maennich@google.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Evolution 3.28.5 (3.28.5-5.el7) Mime-Version: 1.0 X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Mar 2020 17:10:10 -0000 Hi Matthias, On Fri, 2020-03-20 at 12:17 +0100, Matthias Maennich via Elfutils-devel wro= te: > __libelf_decompress would only cleanup zlib resources via inflateEnd() > in case inflating was successful, but would leak memory if not. Fix this > by calling inflateEnd() unconditionally. >=20 > __libelf_decompress did this all the time already, but called > deflateEnd() twice. That is not a (known) issue, but can be cleaned up > by ensuring all error paths use 'return deflate_cleanup' and the success > path calls deflateEnd() only once. Note, the deflate() needs to return > Z_STREAM_END to indicate we are done. Hence change the condition. It was that last condition I had missed. Added a ChangeLog entry and pushed to master. Thanks, Mark