From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:403:478a::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id 0MuKKUk4uWRI3QAASxT56A (envelope-from ) for ; Thu, 20 Jul 2023 15:36:09 +0200 Received: from aspmx1.migadu.com ([2001:41d0:403:478a::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id KLPsKEk4uWR5FQAAauVa8A (envelope-from ) for ; Thu, 20 Jul 2023 15:36:09 +0200 Received: from mail.notmuchmail.org (yantan.tethera.net [IPv6:2a01:4f9:c011:7a79::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 80E066337F for ; Thu, 20 Jul 2023 15:36:09 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2a01:4f9:c011:7a79::1 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1689860169; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-owner:list-unsubscribe:list-subscribe:list-post; bh=fnU8SZIDIMXuZzk3GtDY8oqB5Qxs8n5sCKpzSbtTr84=; b=S8msvsR0BFW+GRbaslZ8qW0gHh0JzQ3mOtpFXTJxhIp1OQyE733Pxjfhx+IIFzN/eARiHm RTv8kNE9yta6Mal1vqg/tlOu/4cQ2cqvxvA+yEBnd92Yrta/K2VQNlQFoTldKSezu95BM6 UC7etZdsSn+lzyDUwmFCmvzRcg8A4KzW5aW/S1o6Ozujx/xvJ6aP2+cJbkmHOk3kEB45uU FJaAdFAOk+qpb3P5fUAcHBXMuFqllqBEw7nD2dwODRECU/ts6caBSc7QieU0uuVonBLz/a 2VArbH8BOC1Jp58Eig0OlM/ouT34F1iOnNti/bPonKsRtgEH79h9svZbqNC82g== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2a01:4f9:c011:7a79::1 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org; dmarc=none ARC-Seal: i=1; s=key1; d=yhetil.org; t=1689860169; a=rsa-sha256; cv=none; b=RjupJPvvwOlWA6oetoEBNelUfJKAAhtBZATrhwqg/wAYD+WCvjCfdKgy/3VPAUZjtj8+WK 0S/xx5LVZvtNirKwm2FvpuhMLz1ZmENcUSHU3MXRh3QC0YfxX2zZsFvU6WNlvdB9TA1uBa eTmJpTKLlIUhTAwwQfRUifm448EWkUh2JXc8WpjllyKLD7OLE0wLM8vmHguO9Y/jfykgEy s2JYBqJm0JtdlQSQtGW2TR6aVNq8R0GsLeFF4axsTnwFnGuLvw6COxYhi4Cn8nidWX+ia5 UjMg5Qs+wC+9lJHjswqeGtXSBzX9zRAMU3WafWalK6Y1gPsYUBwE5dSopPToRw== Received: from yantan.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 0A6835F6BF; Thu, 20 Jul 2023 13:35:56 +0000 (UTC) Received: from phubs.tethera.net (phubs.tethera.net [192.99.9.157]) by mail.notmuchmail.org (Postfix) with ESMTPS id C61475F49F for ; Thu, 20 Jul 2023 13:35:52 +0000 (UTC) Received: from tethera.net (fctnnbsc51w-159-2-210-253.dhcp-dynamic.fibreop.nb.bellaliant.net [159.2.210.253]) by phubs.tethera.net (Postfix) with ESMTPS id 2AF29180178; Thu, 20 Jul 2023 10:35:51 -0300 (ADT) Received: (nullmailer pid 2216445 invoked by uid 1000); Thu, 20 Jul 2023 12:08:25 -0000 From: David Bremner To: notmuch@notmuchmail.org Subject: [PATCH 1/2] lib/message: check message type before deleting document Date: Thu, 20 Jul 2023 09:08:00 -0300 Message-Id: <20230720120801.2215538-2-david@tethera.net> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230720120801.2215538-1-david@tethera.net> References: <20230720120801.2215538-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: 7YEWZDBEZFLU4OHS4YBLR2FNWQL6A4SY X-Message-ID-Hash: 7YEWZDBEZFLU4OHS4YBLR2FNWQL6A4SY X-MailFrom: bremner@tethera.net X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: ukleinek@debian.org X-Mailman-Version: 3.3.3 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN X-Migadu-Country: DE X-Spam-Score: -3.95 X-Migadu-Queue-Id: 80E066337F X-Migadu-Spam-Score: -3.95 X-Migadu-Scanner: mx0.migadu.com X-TUID: LE1cQhu2Oc35 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 --- lib/message.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/message.cc b/lib/message.cc index 53f35dd1..46638f80 100644 --- a/lib/message.cc +++ b/lib/message.cc @@ -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; -- 2.40.1