notmuch segfault

Michal Sojka sojkam1 at fel.cvut.cz
Fri Apr 23 06:37:59 PDT 2010


On Fri, 23 Apr 2010, Sebastian Spaeth wrote:
> Can it be that in thread.cc in _thread_add_matched_message ()
> ...
>     subject = notmuch_message_get_header (message, "subject");
> 
>     if ((strncasecmp (subject, "Re: ", 4) == 0) ||
> ...
> 
> If the underlying message disappeared, get_header will return NULL and
> we pass strncasecmp NULL as first parameter. Could that be?

Yes, it is very likely the problem. The fix is obvious (see bellow), but
the question is how will be this "missing message" presented to the user
e.g. in notmuch show. It may be that we will need some other checks to
not break other things.

diff --git a/lib/thread.cc b/lib/thread.cc
index 5bf8354..29b8336 100644
--- a/lib/thread.cc
+++ b/lib/thread.cc
@@ -148,6 +148,9 @@ _thread_add_matched_message (notmuch_thread_t *thread,
 
     subject = notmuch_message_get_header (message, "subject");
 
+    if (!subject)
+       return;
+
     if ((strncasecmp (subject, "Re: ", 4) == 0) ||
        (strncasecmp (subject, "Aw: ", 4) == 0) ||
        (strncasecmp (subject, "Vs: ", 4) == 0) ||


More information about the notmuch mailing list