aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/thread.cc
diff options
context:
space:
mode:
authorGravatar Carl Worth <cworth@cworth.org>2010-04-24 06:46:43 -0700
committerGravatar Carl Worth <cworth@cworth.org>2010-04-24 06:50:04 -0700
commit3dbef312fbe9b8da247106a177ac58d73b9b9e92 (patch)
treec7ef43b4964d1e022edaa17b270154072975fb23 /lib/thread.cc
parent7c421b87b05d2513540a75bbe1841e226072ad7c (diff)
lib: Audit calls to notmuch_message_get_header to handle NULL return
Sebastian Spaeth reported [*] a segfault within libnotmuch when running notmuch operations while an asyncronous offlineimap job had removed some files from the mail store. Avoid this by handling all cases where notmuch_message_get_header could return NULL. [*] See message id:87d3xqti3o.fsf@SSpaeth.de on notmuch@notmuchmail.org
Diffstat (limited to 'lib/thread.cc')
-rw-r--r--lib/thread.cc10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/thread.cc b/lib/thread.cc
index 1cc22acd..e1da060e 100644
--- a/lib/thread.cc
+++ b/lib/thread.cc
@@ -84,7 +84,7 @@ _thread_add_message (notmuch_thread_t *thread,
{
notmuch_tags_t *tags;
const char *tag;
- InternetAddressList *list;
+ InternetAddressList *list = NULL;
InternetAddress *address;
const char *from, *author;
@@ -97,7 +97,9 @@ _thread_add_message (notmuch_thread_t *thread,
message);
from = notmuch_message_get_header (message, "from");
- list = internet_address_list_parse_string (from);
+ if (from)
+ list = internet_address_list_parse_string (from);
+
if (list) {
address = internet_address_list_get_address (list, 0);
if (address) {
@@ -115,7 +117,7 @@ _thread_add_message (notmuch_thread_t *thread,
if (! thread->subject) {
const char *subject;
subject = notmuch_message_get_header (message, "subject");
- thread->subject = talloc_strdup (thread, subject);
+ thread->subject = talloc_strdup (thread, subject ? subject : "");
}
for (tags = notmuch_message_get_tags (message);
@@ -135,6 +137,8 @@ _thread_set_subject_from_message (notmuch_thread_t *thread,
const char *cleaned_subject;
subject = notmuch_message_get_header (message, "subject");
+ if (! subject)
+ return;
if ((strncasecmp (subject, "Re: ", 4) == 0) ||
(strncasecmp (subject, "Aw: ", 4) == 0) ||