Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 4AC1440DACE for ; Mon, 8 Nov 2010 09:20:05 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -2.89 X-Spam-Level: X-Spam-Status: No, score=-2.89 tagged_above=-999 required=5 tests=[ALL_TRUSTED=-1, BAYES_00=-1.9, T_MIME_NO_TEXT=0.01] autolearn=ham Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id crZTeFN5BWxm; Mon, 8 Nov 2010 09:19:55 -0800 (PST) Received: from yoom.home.cworth.org (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 1355740DAC4; Mon, 8 Nov 2010 09:19:53 -0800 (PST) Received: by yoom.home.cworth.org (Postfix, from userid 1000) id 13AA225412B; Mon, 8 Nov 2010 09:19:50 -0800 (PST) From: Carl Worth To: Michael Forney , notmuch@notmuchmail.org Subject: Re: [PATCH] lib: Fix memory leaks in notmuch_message_file_get_header In-Reply-To: <1288928975-10041-1-git-send-email-mforney@mforney.org> References: <1288928975-10041-1-git-send-email-mforney@mforney.org> User-Agent: Notmuch/0.4 (http://notmuchmail.org) Emacs/23.2.1 (i486-pc-linux-gnu) Date: Mon, 08 Nov 2010 09:19:49 -0800 Message-ID: <877hgnohqi.fsf@yoom.home.cworth.org> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Nov 2010 17:20:05 -0000 --=-=-= Content-Transfer-Encoding: quoted-printable On Thu, 4 Nov 2010 20:49:35 -0700, Michael Forney wr= ote: > When decoded_value, header_sofar, and header are unused, they should > be freed. Thanks for the cleanups here. Just looking over the patch it's clear that I let some code into message-file.c without coercing the style into what I would really prefer to see, (should use talloc more, should move away from overly-abbreviated identifiers such as "hdrsofar", and shouldn't have ambiguously named identifiers such as "header_sofar" and "hdrsofar"). > + free(decoded_value); > + free(header_sofar); > g_hash_table_insert (message->headers, header, combined_header); > } > } else { > if (header_sofar =3D=3D NULL) { > /* Only insert if we don't have a value for this header, yet. */ > g_hash_table_insert (message->headers, header, decoded_value); > + } else { > + free(header); > + free(decoded_value); But I didn't push the change yet. The above do look like memory leak fixes as described in the commit message. > if (match && !is_received) > - return decoded_value; > + return header_sofar =3D=3D NULL ? decoded_value : header_sofar; > } But this part looks like an independent bug fix that needs its own description, (and perhaps a test case?). Could you please split the patch into two? Thanks, =2DCarl =2D-=20 carl.d.worth@intel.com --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iD8DBQFM2DE16JDdNq8qSWgRAtAQAJ9nhgK2kH9mZ0ZAhgbrRd+hMwnx7gCghI/z ia83IEyQ7E5LCEtSdfD4kyo= =MyAu -----END PGP SIGNATURE----- --=-=-=--