1 Return-Path: <mforney@mforney.org>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 9C83F4196F2
\r
6 for <notmuch@notmuchmail.org>; Thu, 4 Nov 2010 20:50:03 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5
\r
12 tests=[BAYES_00=-1.9] autolearn=ham
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id ETcH6hVeVSgB for <notmuch@notmuchmail.org>;
\r
16 Thu, 4 Nov 2010 20:49:53 -0700 (PDT)
\r
17 Received: from mail.mforney.org (mforney.org [65.49.73.30])
\r
18 by olra.theworths.org (Postfix) with ESMTP id 93E8B4196F0
\r
19 for <notmuch@notmuchmail.org>; Thu, 4 Nov 2010 20:49:53 -0700 (PDT)
\r
20 Received: from localhost (hil-100-104.ResHall.Berkeley.EDU [169.229.100.104])
\r
21 by mail.mforney.org (Postfix) with ESMTPSA id 22FC638028;
\r
22 Thu, 4 Nov 2010 20:52:02 -0700 (PDT)
\r
23 From: Michael Forney <mforney@mforney.org>
\r
24 To: notmuch@notmuchmail.org
\r
25 Subject: [PATCH] lib: Fix memory leaks in notmuch_message_file_get_header
\r
26 Date: Thu, 4 Nov 2010 20:49:35 -0700
\r
27 Message-Id: <1288928975-10041-1-git-send-email-mforney@mforney.org>
\r
28 X-Mailer: git-send-email 1.7.2.3
\r
29 Cc: Michael Forney <mforney@mforney.org>
\r
30 X-BeenThere: notmuch@notmuchmail.org
\r
31 X-Mailman-Version: 2.1.13
\r
33 List-Id: "Use and development of the notmuch mail system."
\r
34 <notmuch.notmuchmail.org>
\r
35 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
36 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
37 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
38 List-Post: <mailto:notmuch@notmuchmail.org>
\r
39 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
40 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
41 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
42 X-List-Received-Date: Fri, 05 Nov 2010 03:50:03 -0000
\r
44 When decoded_value, header_sofar, and header are unused, they should be freed.
\r
47 lib/message-file.c | 7 ++++++-
\r
48 1 files changed, 6 insertions(+), 1 deletions(-)
\r
50 diff --git a/lib/message-file.c b/lib/message-file.c
\r
51 index 7722832..1d61577 100644
\r
52 --- a/lib/message-file.c
\r
53 +++ b/lib/message-file.c
\r
54 @@ -341,18 +341,23 @@ notmuch_message_file_get_header (notmuch_message_file_t *message,
\r
55 strncpy(combined_header,header_sofar,hdrsofar);
\r
56 *(combined_header+hdrsofar) = ' ';
\r
57 strncpy(combined_header+hdrsofar+1,decoded_value,newhdr+1);
\r
58 + free(decoded_value);
\r
59 + free(header_sofar);
\r
60 g_hash_table_insert (message->headers, header, combined_header);
\r
63 if (header_sofar == NULL) {
\r
64 /* Only insert if we don't have a value for this header, yet. */
\r
65 g_hash_table_insert (message->headers, header, decoded_value);
\r
68 + free(decoded_value);
\r
71 /* if we found a match we can bail - unless of course we are
\r
72 * collecting all the Received: headers */
\r
73 if (match && !is_received)
\r
74 - return decoded_value;
\r
75 + return header_sofar == NULL ? decoded_value : header_sofar;
\r
78 if (message->parsing_finished) {
\r