mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-25 20:38:08 +01:00
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. Test marked fix by db.
This commit is contained in:
parent
7da6733e89
commit
442d405ad3
2 changed files with 9 additions and 1 deletions
|
@ -28,6 +28,8 @@
|
||||||
#include <glib.h> /* g_free, GPtrArray, GHashTable */
|
#include <glib.h> /* g_free, GPtrArray, GHashTable */
|
||||||
#include <glib-object.h> /* g_type_init */
|
#include <glib-object.h> /* g_type_init */
|
||||||
|
|
||||||
|
#include <gmime/gmime.h> /* g_mime_init */
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
#define ARRAY_SIZE(arr) (sizeof (arr) / sizeof (arr[0]))
|
#define ARRAY_SIZE(arr) (sizeof (arr) / sizeof (arr[0]))
|
||||||
|
@ -585,6 +587,7 @@ notmuch_database_open (const char *path,
|
||||||
struct stat st;
|
struct stat st;
|
||||||
int err;
|
int err;
|
||||||
unsigned int i, version;
|
unsigned int i, version;
|
||||||
|
static int initialized = 0;
|
||||||
|
|
||||||
if (asprintf (¬much_path, "%s/%s", path, ".notmuch") == -1) {
|
if (asprintf (¬much_path, "%s/%s", path, ".notmuch") == -1) {
|
||||||
notmuch_path = NULL;
|
notmuch_path = NULL;
|
||||||
|
@ -608,6 +611,12 @@ notmuch_database_open (const char *path,
|
||||||
/* Initialize the GLib type system and threads */
|
/* Initialize the GLib type system and threads */
|
||||||
g_type_init ();
|
g_type_init ();
|
||||||
|
|
||||||
|
/* Initialize gmime */
|
||||||
|
if (! initialized) {
|
||||||
|
g_mime_init (0);
|
||||||
|
initialized = 1;
|
||||||
|
}
|
||||||
|
|
||||||
notmuch = talloc (NULL, notmuch_database_t);
|
notmuch = talloc (NULL, notmuch_database_t);
|
||||||
notmuch->exception_reported = FALSE;
|
notmuch->exception_reported = FALSE;
|
||||||
notmuch->path = talloc_strdup (notmuch, path);
|
notmuch->path = talloc_strdup (notmuch, path);
|
||||||
|
|
|
@ -5,7 +5,6 @@ test_description="python bindings"
|
||||||
add_email_corpus
|
add_email_corpus
|
||||||
|
|
||||||
test_begin_subtest "compare thread ids"
|
test_begin_subtest "compare thread ids"
|
||||||
test_subtest_known_broken
|
|
||||||
test_python <<EOF
|
test_python <<EOF
|
||||||
import notmuch
|
import notmuch
|
||||||
db = notmuch.Database(mode=notmuch.Database.MODE.READ_WRITE)
|
db = notmuch.Database(mode=notmuch.Database.MODE.READ_WRITE)
|
||||||
|
|
Loading…
Reference in a new issue