X-Git-Url: https://git.notmuchmail.org/git?a=blobdiff_plain;f=lib%2Fdatabase.cc;h=207246cc5dc0387a04083c460b869515614fd970;hb=d746688bebf76e2ba276ae965c9372670607c68f;hp=65478b8a30c4ec217c293c95675d0090afa25dba;hpb=0da0131096c83311b91b00bd72f05fb1902c595d;p=notmuch diff --git a/lib/database.cc b/lib/database.cc index 65478b8a..207246cc 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -185,7 +185,7 @@ notmuch_status_to_string (notmuch_status_t status) case NOTMUCH_STATUS_TAG_TOO_LONG: return "Tag value is too long (exceeds NOTMUCH_TAG_MAX)"; case NOTMUCH_STATUS_UNBALANCED_FREEZE_THAW: - return "Unblanced number of calls to notmuch_message_freeze/thaw"; + return "Unbalanced number of calls to notmuch_message_freeze/thaw"; default: case NOTMUCH_STATUS_LAST_STATUS: return "Unknown error status value"; @@ -323,7 +323,7 @@ _parse_message_id (void *ctx, const char *message_id, const char **next) const char *s, *end; char *result; - if (message_id == NULL) + if (message_id == NULL || *message_id == '\0') return NULL; s = message_id; @@ -391,7 +391,7 @@ parse_references (void *ctx, { char *ref; - if (refs == NULL) + if (refs == NULL || *refs == '\0') return; while (*refs) { @@ -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", @@ -895,9 +896,9 @@ notmuch_database_add_message (notmuch_database_t *notmuch, subject = notmuch_message_file_get_header (message_file, "subject"); to = notmuch_message_file_get_header (message_file, "to"); - if (from == NULL && - subject == NULL && - to == NULL) + if ((from == NULL || *from == '\0') && + (subject == NULL || *subject == '\0') && + (to == NULL || *to == '\0')) { ret = NOTMUCH_STATUS_FILE_NOT_EMAIL; goto DONE; @@ -907,7 +908,7 @@ notmuch_database_add_message (notmuch_database_t *notmuch, * is to find a message ID (or else create one ourselves). */ header = notmuch_message_file_get_header (message_file, "message-id"); - if (header) { + if (header && *header != '\0') { message_id = _parse_message_id (message_file, header, NULL); /* So the header value isn't RFC-compliant, but it's * better than no message-id at all. */ @@ -939,8 +940,11 @@ notmuch_database_add_message (notmuch_database_t *notmuch, talloc_free (message_id); - if (message == NULL) + if (message == NULL) { + ret = COERCE_STATUS (private_status, + "Unexpected status value from _notmuch_message_create_for_message_id"); goto DONE; + } /* Is this a newly created message object? */ if (private_status == NOTMUCH_PRIVATE_STATUS_NO_DOCUMENT_FOUND) {