]> git.notmuchmail.org Git - notmuch/blobdiff - lib/database.cc
linke_message: Avoid segfault when In-Reply-to header is empty.
[notmuch] / lib / database.cc
index 5b677d42007fcae27e2632701d2c4073a664e44b..ce9a86bfddb8b525a19ecefe27d443bb803a8d01 100644 (file)
@@ -317,7 +317,7 @@ skip_space_and_comments (const char **str)
  * Returns a newly talloc'ed string belonging to 'ctx'.
  *
  * Returns NULL if there is any error parsing the message-id. */
-char *
+static char *
 _parse_message_id (void *ctx, const char *message_id, const char **next)
 {
     const char *s, *end;
@@ -726,7 +726,8 @@ _notmuch_database_link_message_to_parents (notmuch_database_t *notmuch,
 
     /* Carefully avoid adding any self-referential in-reply-to term. */
     in_reply_to_message_id = _parse_message_id (message, in_reply_to, NULL);
-    if (strcmp (in_reply_to_message_id,
+    if (in_reply_to_message_id &&
+       strcmp (in_reply_to_message_id,
                notmuch_message_get_message_id (message)))
     {
        _notmuch_message_add_term (message, "replyto",