[RFC PATCH] test: add devel/test-in-docker.sh
[notmuch-archives.git] / cb / f2af3d11a9007ffcc96e4f0444fe43a3984050
1 Return-Path: <bremner@tesseract.cs.unb.ca>\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 6A0F2431E82\r
6         for <notmuch@notmuchmail.org>; Sun, 28 Dec 2014 02:45:43 -0800 (PST)\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 yneXMn95Pp1K for <notmuch@notmuchmail.org>;\r
16         Sun, 28 Dec 2014 02:45:40 -0800 (PST)\r
17 Received: from yantan.tethera.net (yantan.tethera.net [199.188.72.155])\r
18         (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits))\r
19         (No client certificate requested)\r
20         by olra.theworths.org (Postfix) with ESMTPS id 376F6431FAE\r
21         for <notmuch@notmuchmail.org>; Sun, 28 Dec 2014 02:45:40 -0800 (PST)\r
22 Received: from remotemail by yantan.tethera.net with local (Exim 4.80)\r
23         (envelope-from <bremner@tesseract.cs.unb.ca>)\r
24         id 1Y5BLs-0007ep-Jh; Sun, 28 Dec 2014 06:45:36 -0400\r
25 Received: (nullmailer pid 12358 invoked by uid 1000); Sun, 28 Dec 2014\r
26         10:45:31 -0000\r
27 From: David Bremner <david@tethera.net>\r
28 To: notmuch@notmuchmail.org\r
29 Subject: [PATCH] lib: another iterator-temporary/stale-pointer bug\r
30 Date: Sun, 28 Dec 2014 11:45:08 +0100\r
31 Message-Id: <1419763508-11902-1-git-send-email-david@tethera.net>\r
32 X-Mailer: git-send-email 2.1.3\r
33 In-Reply-To: <20141226230655.GA41992@pamparam>\r
34 References: <20141226230655.GA41992@pamparam>\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: Sun, 28 Dec 2014 10:45:43 -0000\r
48 \r
49 Tamas Szakaly points out [1] that the bug fixed in 51b073c still\r
50 exists in at least one place. This change follows the suggestion of\r
51 [2] and creates a block scope temporary std::string to avoid the rules\r
52 of iterators temporaries.\r
53 \r
54 [1]: id:20141226113755.GA64154@pamparam\r
55 [2]: id:20141226230655.GA41992@pamparam\r
56 ---\r
57 \r
58 I decided to take a more minimalist approach than [2]. In particular\r
59 using "direntry" for two different things seemed slightly trickier\r
60 than necessary, for no obvious performance gain (calling .c_str()\r
61 should be cheap).\r
62 \r
63 lib/message.cc | 5 +++--\r
64  1 file changed, 3 insertions(+), 2 deletions(-)\r
65 \r
66 diff --git a/lib/message.cc b/lib/message.cc\r
67 index a7a13cc..bacb4d4 100644\r
68 --- a/lib/message.cc\r
69 +++ b/lib/message.cc\r
70 @@ -641,15 +641,16 @@ _notmuch_message_add_directory_terms (void *ctx, notmuch_message_t *message)\r
71         unsigned int directory_id;\r
72         const char *direntry, *directory;\r
73         char *colon;\r
74 +       const std::string term = *i;\r
75  \r
76         /* Terminate loop at first term without desired prefix. */\r
77 -       if (strncmp ((*i).c_str (), direntry_prefix, direntry_prefix_len))\r
78 +       if (strncmp (term.c_str (), direntry_prefix, direntry_prefix_len))\r
79             break;\r
80  \r
81         /* Indicate that there are filenames remaining. */\r
82         status = NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID;\r
83  \r
84 -       direntry = (*i).c_str ();\r
85 +       direntry = term.c_str ();\r
86         direntry += direntry_prefix_len;\r
87  \r
88         directory_id = strtol (direntry, &colon, 10);\r
89 -- \r
90 2.1.3\r
91 \r