Re: [PATCH 1/2] Add Google Inc. to AUTHORS as a contributor.
[notmuch-archives.git] / eb / fe554d1a0cec5dde29f550e09c9c4a1eea6a28
1 Return-Path: <kaz.rag@gmail.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 9DD6C429E30\r
6         for <notmuch@notmuchmail.org>; Fri, 30 Dec 2011 20:37:58 -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.799\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] 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 NTCXQMuUA1-u for <notmuch@notmuchmail.org>;\r
17         Fri, 30 Dec 2011 20:37:57 -0800 (PST)\r
18 Received: from mail-qy0-f181.google.com (mail-qy0-f181.google.com\r
19         [209.85.216.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id 9CDEE431FD0\r
22         for <notmuch@notmuchmail.org>; Fri, 30 Dec 2011 20:37:57 -0800 (PST)\r
23 Received: by mail-qy0-f181.google.com with SMTP id a6so11114857qch.26\r
24         for <notmuch@notmuchmail.org>; Fri, 30 Dec 2011 20:37:57 -0800 (PST)\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
26         h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;\r
27         bh=ROaKvGrTyuvu7oQ9Z0Wa8lBbgByBYdnrWCWklE0S29A=;\r
28         b=N3LvO4Xw7ZpE5YKGnEMG4W3LgLZphPTMO0oOVCquCgidZ8H3F52QCri3ivXIxazNLD\r
29         33ndg+la8nEexxkHRFRpYxJMeo8zBndzcc4cjKSNaWjeET2K/VKtyMkt4/aNImaUF7ht\r
30         nweOzN3h8QnjPbQsVy0Gl7NpylAWav+F2T7Lk=\r
31 Received: by 10.224.42.10 with SMTP id q10mr33145579qae.26.1325306277270;\r
32         Fri, 30 Dec 2011 20:37:57 -0800 (PST)\r
33 Received: from localhost.localdomain (201-1-35-143.dsl.telesp.net.br.\r
34         [201.1.35.143])\r
35         by mx.google.com with ESMTPS id r10sm76863833qaz.7.2011.12.30.20.37.55\r
36         (version=TLSv1/SSLv3 cipher=OTHER);\r
37         Fri, 30 Dec 2011 20:37:56 -0800 (PST)\r
38 From: Kazuo Teramoto <kaz.rag@gmail.com>\r
39 To: david@tethera.net,\r
40         notmuch@notmuchmail.org\r
41 Subject: [PATCH] lib: call g_mime_init() from notmuch_database_open()\r
42 Date: Sat, 31 Dec 2011 02:37:41 -0200\r
43 Message-Id: <1325306261-21444-2-git-send-email-kaz.rag@gmail.com>\r
44 X-Mailer: git-send-email 1.7.8.1\r
45 In-Reply-To: <1325306261-21444-1-git-send-email-kaz.rag@gmail.com>\r
46 References: <87hb0h5tps.fsf@zancas.localnet>\r
47         <1325306261-21444-1-git-send-email-kaz.rag@gmail.com>\r
48 X-BeenThere: notmuch@notmuchmail.org\r
49 X-Mailman-Version: 2.1.13\r
50 Precedence: list\r
51 List-Id: "Use and development of the notmuch mail system."\r
52         <notmuch.notmuchmail.org>\r
53 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
54         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
55 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
56 List-Post: <mailto:notmuch@notmuchmail.org>\r
57 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
58 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
59         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
60 X-List-Received-Date: Sat, 31 Dec 2011 04:37:59 -0000\r
61 \r
62 As reported in\r
63 id:"CAEbOPGyuHnz4BPtDutnTPUHcP3eYcRCRkXhYoJR43RUMw671+g@mail.gmail.com"\r
64 sometimes gmime try to access a NULL pointer, e.g. g_mime_iconv_open()\r
65 try to access iconv_cache that is NULL if g_mime_init() is not called.\r
66 This cause notmuch to segfault when calling gmime functions.\r
67 \r
68 Calling g_mime_init() initialize iconv_cache and others variables needed\r
69 by gmime, making sure they are initialized when notmuch calls gmime\r
70 functions.\r
71 ---\r
72  lib/database.cc |    9 +++++++++\r
73  1 files changed, 9 insertions(+), 0 deletions(-)\r
74 \r
75 diff --git a/lib/database.cc b/lib/database.cc\r
76 index d11dfaf..8103bd9 100644\r
77 --- a/lib/database.cc\r
78 +++ b/lib/database.cc\r
79 @@ -28,6 +28,8 @@\r
80  #include <glib.h> /* g_free, GPtrArray, GHashTable */\r
81  #include <glib-object.h> /* g_type_init */\r
82  \r
83 +#include <gmime/gmime.h> /* g_mime_init */\r
84 +\r
85  using namespace std;\r
86  \r
87  #define ARRAY_SIZE(arr) (sizeof (arr) / sizeof (arr[0]))\r
88 @@ -585,6 +587,7 @@ notmuch_database_open (const char *path,\r
89      struct stat st;\r
90      int err;\r
91      unsigned int i, version;\r
92 +    static int initialized = 0;\r
93  \r
94      if (asprintf (&notmuch_path, "%s/%s", path, ".notmuch") == -1) {\r
95         notmuch_path = NULL;\r
96 @@ -608,6 +611,12 @@ notmuch_database_open (const char *path,\r
97      /* Initialize the GLib type system and threads */\r
98      g_type_init ();\r
99  \r
100 +    /* Initialize gmime */\r
101 +    if (! initialized) {\r
102 +       g_mime_init (0);\r
103 +       initialized = 1;\r
104 +    }\r
105 +\r
106      notmuch = talloc (NULL, notmuch_database_t);\r
107      notmuch->exception_reported = FALSE;\r
108      notmuch->path = talloc_strdup (notmuch, path);\r
109 -- \r
110 1.7.8.1\r
111 \r