Re: bug#6214: 23.1; json-read-string crashes emacs with long string
[notmuch-archives.git] / 1b / fb2a5d0992ce2b400f09652b23bb26dc4056fd
1 Return-Path: <BATV+3d395db9405134d2e00f+2417+infradead.org+hohndel@bombadil.srs.infradead.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 AEC474196F4\r
6         for <notmuch@notmuchmail.org>; Tue,  6 Apr 2010 12:45:32 -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: -1.5\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-1.5 tagged_above=-999 required=5\r
12         tests=[BAYES_50=0.8, RCVD_IN_DNSWL_MED=-2.3] 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 1Sf0kARRGCAB for <notmuch@notmuchmail.org>;\r
16         Tue,  6 Apr 2010 12:45:31 -0700 (PDT)\r
17 Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34])\r
18         by olra.theworths.org (Postfix) with ESMTP id A1C0C4196F0\r
19         for <notmuch@notmuchmail.org>; Tue,  6 Apr 2010 12:45:31 -0700 (PDT)\r
20 Received: from localhost ([::1] helo=localhost.localdomain)\r
21         by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux))\r
22         id 1NzEiI-0003UJ-Ui\r
23         for notmuch@notmuchmail.org; Tue, 06 Apr 2010 19:45:31 +0000\r
24 Received: by localhost.localdomain (Postfix, from userid 500)\r
25         id 6419AC007F; Tue,  6 Apr 2010 12:45:30 -0700 (PDT)\r
26 From: Dirk Hohndel <hohndel@infradead.org>\r
27 To: notmuch <notmuch@notmuchmail.org>\r
28 Subject: [PATCH 1/2] fix notmuch_message_file_get_header\r
29 Date: Tue, 06 Apr 2010 12:45:30 -0700\r
30 Message-ID: <m3tyroxt45.fsf@x200.gr8dns.org>\r
31 MIME-Version: 1.0\r
32 Content-Type: text/plain; charset=us-ascii\r
33 X-SRS-Rewrite: SMTP reverse-path rewritten from <hohndel@infradead.org> by\r
34         bombadil.infradead.org See http://www.infradead.org/rpr.html\r
35 X-BeenThere: notmuch@notmuchmail.org\r
36 X-Mailman-Version: 2.1.13\r
37 Precedence: list\r
38 List-Id: "Use and development of the notmuch mail system."\r
39         <notmuch.notmuchmail.org>\r
40 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
41         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
42 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
43 List-Post: <mailto:notmuch@notmuchmail.org>\r
44 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
45 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
46         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
47 X-List-Received-Date: Tue, 06 Apr 2010 19:45:32 -0000\r
48 \r
49 \r
50  fix notmuch_message_file_get_header to always return the first instance\r
51  of the header you are looking for\r
52 \r
53 \r
54 Signed-off-by: Dirk Hohndel <hohndel@infradead.org>\r
55 ---\r
56  lib/message-file.c |   12 +++++++++---\r
57  1 files changed, 9 insertions(+), 3 deletions(-)\r
58 \r
59 diff --git a/lib/message-file.c b/lib/message-file.c\r
60 index 3a1a681..0c152a3 100644\r
61 --- a/lib/message-file.c\r
62 +++ b/lib/message-file.c\r
63 @@ -318,9 +318,15 @@ notmuch_message_file_get_header (notmuch_message_file_t *message,\r
64             match = (strcasecmp (header, header_desired) == 0);\r
65  \r
66         decoded_value = g_mime_utils_header_decode_text (message->value.str);\r
67 -\r
68 -       g_hash_table_insert (message->headers, header, decoded_value);\r
69 -\r
70 +       if (g_hash_table_lookup (message->headers, header) == NULL) {\r
71 +           /* Only insert if we don't have a value for this header, yet.\r
72 +            * This way we always return the FIRST instance of any header\r
73 +            * we search for\r
74 +            * FIXME: we should be returning ALL instances of a header\r
75 +            *        or at least provide a way to iterate over them\r
76 +            */\r
77 +           g_hash_table_insert (message->headers, header, decoded_value);\r
78 +       }\r
79         if (match)\r
80             return decoded_value;\r
81      }\r
82 -- \r
83 1.6.6.1\r
84 \r
85 \r
86 -- \r
87 Dirk Hohndel\r
88 Intel Open Source Technology Center\r