Re: [PATCH 03/13] sprinter: Add a string_len method
[notmuch-archives.git] / b4 / 82586a152435a926f860e98b0270fe804c623c
1 Return-Path: <anton@khirnov.net>\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 F1407431FB6\r
6         for <notmuch@notmuchmail.org>; Fri, 15 Apr 2011 08:15:44 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
12         autolearn=disabled\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 20Gz1Es77-z5 for <notmuch@notmuchmail.org>;\r
16         Fri, 15 Apr 2011 08:15:44 -0700 (PDT)\r
17 X-Greylist: delayed 1899 seconds by postgrey-1.32 at olra;\r
18         Fri, 15 Apr 2011 08:15:44 PDT\r
19 Received: from smtp1.kolej.mff.cuni.cz (smtp1.kolej.mff.cuni.cz\r
20         [78.128.192.10])\r
21         (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
22         (No client certificate requested)\r
23         by olra.theworths.org (Postfix) with ESMTPS id 30F11431FB5\r
24         for <notmuch@notmuchmail.org>; Fri, 15 Apr 2011 08:15:43 -0700 (PDT)\r
25 X-Envelope-From: anton@khirnov.net\r
26 Received: from zohar.localdomain (zohar.kolej.mff.cuni.cz [78.128.198.199])\r
27         by smtp1.kolej.mff.cuni.cz (8.14.4/8.14.4) with ESMTP id p3FEi073098097\r
28         for <notmuch@notmuchmail.org>; Fri, 15 Apr 2011 16:44:02 +0200 (CEST)\r
29         (envelope-from anton@khirnov.net)\r
30 Received: by zohar.localdomain (Postfix, from userid 1000)\r
31         id 9D6917F7D8; Fri, 15 Apr 2011 16:44:00 +0200 (CEST)\r
32 From: Anton Khirnov <anton@khirnov.net>\r
33 To: notmuch@notmuchmail.org\r
34 Subject: [PATCH] lib/message-file: plug three memleaks.\r
35 Date: Fri, 15 Apr 2011 16:43:58 +0200\r
36 Message-Id: <1302878638-17634-1-git-send-email-anton@khirnov.net>\r
37 X-Mailer: git-send-email 1.7.4.1\r
38 X-BeenThere: notmuch@notmuchmail.org\r
39 X-Mailman-Version: 2.1.13\r
40 Precedence: list\r
41 List-Id: "Use and development of the notmuch mail system."\r
42         <notmuch.notmuchmail.org>\r
43 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
44         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
45 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
46 List-Post: <mailto:notmuch@notmuchmail.org>\r
47 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
48 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
49         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
50 X-List-Received-Date: Fri, 15 Apr 2011 15:15:45 -0000\r
51 \r
52 ---\r
53  lib/message-file.c |    5 +++++\r
54  1 files changed, 5 insertions(+), 0 deletions(-)\r
55 \r
56 diff --git a/lib/message-file.c b/lib/message-file.c\r
57 index 7722832..b7b3286 100644\r
58 --- a/lib/message-file.c\r
59 +++ b/lib/message-file.c\r
60 @@ -341,12 +341,17 @@ notmuch_message_file_get_header (notmuch_message_file_t *message,\r
61                 strncpy(combined_header,header_sofar,hdrsofar);\r
62                 *(combined_header+hdrsofar) = ' ';\r
63                 strncpy(combined_header+hdrsofar+1,decoded_value,newhdr+1);\r
64 +               free(decoded_value);\r
65                 g_hash_table_insert (message->headers, header, combined_header);\r
66             }\r
67         } else {\r
68             if (header_sofar == NULL) {\r
69                 /* Only insert if we don't have a value for this header, yet. */\r
70                 g_hash_table_insert (message->headers, header, decoded_value);\r
71 +           } else {\r
72 +               free(header);\r
73 +               free(decoded_value);\r
74 +               decoded_value = header_sofar;\r
75             }\r
76         }\r
77         /* if we found a match we can bail - unless of course we are\r
78 -- \r
79 1.7.4.1\r
80 \r