1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
From 5f4dad1b12e224f06576e5ed9e71b3f9f16a13f1 Mon Sep 17 00:00:00 2001
From: Kazuo Teramoto <kaz.rag@gmail.com>
Date: Sat, 31 Dec 2011 02:37:41 -0200
Subject: [PATCH 3/3] lib: call g_mime_init() from notmuch_database_open()
As reported in
id:"CAEbOPGyuHnz4BPtDutnTPUHcP3eYcRCRkXhYoJR43RUMw671+g@mail.gmail.com"
sometimes gmime tries to access a NULL pointer, e.g. g_mime_iconv_open()
tries to access iconv_cache that is NULL if g_mime_init() is not called.
This causes notmuch to segfault when calling gmime functions.
Calling g_mime_init() initializes iconv_cache and others variables needed
by gmime, making sure they are initialized when notmuch calls gmime
functions.
---
lib/database.cc | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/lib/database.cc b/lib/database.cc
index 98f101e..df6c8d0 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -28,6 +28,8 @@
#include <glib.h> /* g_free, GPtrArray, GHashTable */
#include <glib-object.h> /* g_type_init */
+#include <gmime/gmime.h> /* g_mime_init */
+
using namespace std;
#define ARRAY_SIZE(arr) (sizeof (arr) / sizeof (arr[0]))
@@ -581,6 +583,7 @@ notmuch_database_open (const char *path,
struct stat st;
int err;
unsigned int i, version;
+ static int initialized = 0;
if (asprintf (¬much_path, "%s/%s", path, ".notmuch") == -1) {
notmuch_path = NULL;
@@ -604,6 +607,12 @@ notmuch_database_open (const char *path,
/* Initialize the GLib type system and threads */
g_type_init ();
+ /* Initialize gmime */
+ if (! initialized) {
+ g_mime_init (0);
+ initialized = 1;
+ }
+
notmuch = talloc (NULL, notmuch_database_t);
notmuch->exception_reported = FALSE;
notmuch->path = talloc_strdup (notmuch, path);
--
1.7.8.4
|