Re: [PATCH] configure: add --without-api-docs option
[notmuch-archives.git] / 10 / c20831bf128cbd81367b981caca063a0f8babf
1 Return-Path: <cworth@cworth.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 C159A431FBF;\r
6         Fri, 20 Nov 2009 03:32:53 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 Received: from olra.theworths.org ([127.0.0.1])\r
9         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
10         with ESMTP id 6-J3w3sPASPE; Fri, 20 Nov 2009 03:32:52 -0800 (PST)\r
11 Received: from cworth.org (localhost [127.0.0.1])\r
12         by olra.theworths.org (Postfix) with ESMTP id 4092D431FAE;\r
13         Fri, 20 Nov 2009 03:32:52 -0800 (PST)\r
14 From: Carl Worth <cworth@cworth.org>\r
15 To: Adrian Perez de Castro <aperez@igalia.com>, notmuch@notmuchmail.org,\r
16         Jeffrey Ollie <jeff@ocjtech.us>, Not Much Mail <notmuch@notmuchmail.org>\r
17 In-Reply-To: <935ead450911191823s776fda6eyb6f6949ac982bd03@mail.gmail.com>\r
18 References: <935ead450911181000w2cddfe95qe9efd5bea9f9209d@mail.gmail.com>\r
19         <20091119164543.25e7afe5@hikari>\r
20         <935ead450911191823s776fda6eyb6f6949ac982bd03@mail.gmail.com>\r
21 Date: Fri, 20 Nov 2009 12:32:41 +0100\r
22 Message-ID: <87lji11leu.fsf@yoom.home.cworth.org>\r
23 MIME-Version: 1.0\r
24 Content-Type: text/plain; charset=us-ascii\r
25 Subject: Re: [notmuch] Segfault searching for tags\r
26 X-BeenThere: notmuch@notmuchmail.org\r
27 X-Mailman-Version: 2.1.12\r
28 Precedence: list\r
29 List-Id: "Use and development of the notmuch mail system."\r
30         <notmuch.notmuchmail.org>\r
31 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
32         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
33 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
34 List-Post: <mailto:notmuch@notmuchmail.org>\r
35 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
36 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
37         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
38 X-List-Received-Date: Fri, 20 Nov 2009 11:32:53 -0000\r
39 \r
40 On Thu, 19 Nov 2009 16:45:43 +0100, Adrian Perez de Castro <aperez@igalia.com> wrote:\r
41 > The thing is that in notmuch_message_get_in_reply_to(), line 288, a NULL\r
42 > instance of Xapian::TermIterator is dereferenced. In my particular case,\r
43 > the culpript is a cache file of Claws-Mail, as seen in the following GDB\r
44 > session:\r
45 \r
46 Not quite NULL, (nor is it quite dereferencing---this is nasty C++\r
47 overloading), but yeah, the idea is the same. We need to protect all of\r
48 our "calls" to this overloaded operator to not call it when the iterator\r
49 is equal to the value returned by termlist_end ().\r
50 \r
51 On Thu, 19 Nov 2009 20:23:15 -0600, Jeffrey Ollie <jeff@ocjtech.us> wrote:\r
52 > I straced some of the crashes, and the last file that was read before\r
53 > the crash was a malformed message.  I've attached one of the messages.\r
54 >  I've been using offlineimap to sync my gmail mailbox to my laptop so\r
55 > that I can use notmuch.  offlineimap isn't the most stable program,\r
56 > but I'm not sure yet if offlineimap is causing the problem or if\r
57 > that's the way the message is in gmail.\r
58 \r
59 Thanks for the file. I never like to push code that I haven't tested, so\r
60 this was very helpful.\r
61 \r
62 Below is the patch that I just pushed which seems to do the trick.\r
63 \r
64 -Carl\r
65 \r
66 commit 31b54bc78735c628035a046e526ac4c596d830cf\r
67 Author: Carl Worth <cworth@cworth.org>\r
68 Date:   Fri Nov 20 12:06:11 2009 +0100\r
69 \r
70     Avoid access of a Xapian iterator's object when there's nothing\r
71     there.\r
72     \r
73     This eliminates a crash when a message (either corrupted or a\r
74     non-mail\r
75     file that wasn't properly detected as not being mail) has no\r
76     In-Reply-To\r
77     header, (and so few terms that trying to skip to the prefix of the\r
78     In-Reply-To terms actually brings us to the end of the termlist).\r
79 \r
80 diff --git a/lib/message.cc b/lib/message.cc\r
81 index 9488fb6..41dddd0 100644\r
82 --- a/lib/message.cc\r
83 +++ b/lib/message.cc\r
84 @@ -285,7 +285,8 @@ _notmuch_message_get_in_reply_to (notmuch_message_t\r
85 *message\r
86      i = message->doc.termlist_begin ();\r
87      i.skip_to (prefix);\r
88  \r
89 -    in_reply_to = *i;\r
90 +    if (i != message->doc.termlist_end ())\r
91 +       in_reply_to = *i;\r
92  \r
93      /* It's perfectly valid for a message to have no In-Reply-To\r
94       * header. For these cases, we return an empty string. */\r
95 @@ -332,10 +333,10 @@ notmuch_message_get_thread_id (notmuch_message_t\r
96      *message)\r
97         return message->thread_id;\r
98  \r
99      i = message->doc.termlist_begin ();\r
100 -\r
101      i.skip_to (prefix);\r
102  \r
103 -    id = *i;\r
104 +    if (i != message->doc.termlist_end ())\r
105 +       id = *i;\r
106  \r
107      if (i == message->doc.termlist_end () || id[0] != *prefix)\r
108         INTERNAL_ERROR ("Message with document ID of %d has no thread\r
109         ID.\n",\r
110 @@ -466,7 +467,7 @@ notmuch_message_get_tags (notmuch_message_t\r
111         *message)\r
112  \r
113      i.skip_to (prefix);\r
114  \r
115 -    while (1) {\r
116 +    while (i != end) {\r
117         tag = *i;\r
118  \r
119         if (tag.empty () || tag[0] != *prefix)\r