mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-12-03 16:14:11 +01:00
lib/message: check message type before deleting document
It isn't really clear how this worked before. Traversing the terms of a document after deleting it from the database seems likely to be undefined behaviour at best
This commit is contained in:
parent
08ca74d715
commit
d93d49b6ae
1 changed files with 3 additions and 2 deletions
|
@ -1397,14 +1397,15 @@ _notmuch_message_delete (notmuch_message_t *message)
|
|||
Xapian::PostingIterator thread_doc, thread_doc_end;
|
||||
Xapian::PostingIterator mail_doc, mail_doc_end;
|
||||
|
||||
message->notmuch->writable_xapian_db->delete_document (message->doc_id);
|
||||
|
||||
/* look for a non-ghost message in the same thread */
|
||||
/* if this was a ghost to begin with, we are done */
|
||||
private_status = _notmuch_message_has_term (message, "type", "ghost", &is_ghost);
|
||||
if (private_status)
|
||||
return COERCE_STATUS (private_status,
|
||||
"Error trying to determine whether message was a ghost");
|
||||
|
||||
message->notmuch->writable_xapian_db->delete_document (message->doc_id);
|
||||
|
||||
if (is_ghost)
|
||||
return NOTMUCH_STATUS_SUCCESS;
|
||||
|
||||
|
|
Loading…
Reference in a new issue