Re: Avoiding the "huge INBOX of death"
[notmuch-archives.git] / da / e89f8075d1d9c3df0f9925485ad26eae86032d
1 Return-Path: <Vladimir.Marek@oracle.com>\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 EA317431FB6\r
6         for <notmuch@notmuchmail.org>; Wed,  1 May 2013 14:34:03 -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: -2.299\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-2.299 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_MED=-2.3, UNPARSEABLE_RELAY=0.001]\r
13         autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id KPKT6fppHipA for <notmuch@notmuchmail.org>;\r
17         Wed,  1 May 2013 14:33:59 -0700 (PDT)\r
18 Received: from userp1040.oracle.com (userp1040.oracle.com [156.151.31.81])\r
19         (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id 4EA5C431FAF\r
22         for <notmuch@notmuchmail.org>; Wed,  1 May 2013 14:33:59 -0700 (PDT)\r
23 Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93])\r
24         by userp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with\r
25         ESMTP id r41LXuA4020955\r
26         (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK);\r
27         Wed, 1 May 2013 21:33:57 GMT\r
28 Received: from aserz7022.oracle.com (aserz7022.oracle.com [141.146.126.231])\r
29         by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id\r
30         r41LXusY009397\r
31         (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL);\r
32         Wed, 1 May 2013 21:33:57 GMT\r
33 Received: from abhmt114.oracle.com (abhmt114.oracle.com [141.146.116.66])\r
34         by aserz7022.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id\r
35         r41LXu54019922; Wed, 1 May 2013 21:33:56 GMT\r
36 Received: from tbd.cz.oracle.com (/10.163.101.124)\r
37         by default (Oracle Beehive Gateway v4.0)\r
38         with ESMTP ; Wed, 01 May 2013 14:33:55 -0700\r
39 From: Vladimir.Marek@oracle.com\r
40 To: notmuch@notmuchmail.org\r
41 Subject: [PATCH 01/24] lib/message.cc: stale pointer bug\r
42 Date: Wed,  1 May 2013 23:33:41 +0200\r
43 Message-Id: <1367444021-2757-1-git-send-email-Vladimir.Marek@oracle.com>\r
44 X-Mailer: git-send-email 1.7.9.2\r
45 X-Source-IP: ucsinet21.oracle.com [156.151.31.93]\r
46 Cc: Vladimir Marek <vlmarek@volny.cz>\r
47 X-BeenThere: notmuch@notmuchmail.org\r
48 X-Mailman-Version: 2.1.13\r
49 Precedence: list\r
50 List-Id: "Use and development of the notmuch mail system."\r
51         <notmuch.notmuchmail.org>\r
52 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
53         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
54 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
55 List-Post: <mailto:notmuch@notmuchmail.org>\r
56 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
57 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
58         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
59 X-List-Received-Date: Wed, 01 May 2013 21:34:04 -0000\r
60 \r
61 From: Vladimir Marek <vlmarek@volny.cz>\r
62 \r
63 Xapian::TermIterator::operator* returns std::string which is destroyed\r
64 as soon as (*i).c_str() finishes. The remembered pointer 'term' then\r
65 references invalid memory.\r
66 \r
67 Signed-off-by: Vladimir Marek <vlmarek@volny.cz>\r
68 ---\r
69  lib/message.cc |   11 ++++++-----\r
70  1 file changed, 6 insertions(+), 5 deletions(-)\r
71 \r
72 diff --git a/lib/message.cc b/lib/message.cc\r
73 index 8720c1b..a890550 100644\r
74 --- a/lib/message.cc\r
75 +++ b/lib/message.cc\r
76 @@ -266,18 +266,19 @@ _notmuch_message_get_term (notmuch_message_t *message,\r
77                            const char *prefix)\r
78  {\r
79      int prefix_len = strlen (prefix);\r
80 -    const char *term = NULL;\r
81 +    std::string term;\r
82      char *value;\r
83  \r
84      i.skip_to (prefix);\r
85  \r
86 -    if (i != end)\r
87 -       term = (*i).c_str ();\r
88 +    if (i == end)\r
89 +       return NULL;\r
90  \r
91 -    if (!term || strncmp (term, prefix, prefix_len))\r
92 +    term = *i;\r
93 +    if (strncmp (term.c_str(), prefix, prefix_len))\r
94         return NULL;\r
95  \r
96 -    value = talloc_strdup (message, term + prefix_len);\r
97 +    value = talloc_strdup (message, term.c_str() + prefix_len);\r
98  \r
99  #if DEBUG_DATABASE_SANITY\r
100      i++;\r
101 -- \r
102 1.7.9.2\r
103 \r