From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id UFOyHTcKjmIGDwEAbAwnHQ (envelope-from ) for ; Wed, 25 May 2022 12:51:35 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id yFmEHTcKjmL4+QAAauVa8A (envelope-from ) for ; Wed, 25 May 2022 12:51:35 +0200 Received: from mail.notmuchmail.org (yantan.tethera.net [135.181.149.255]) (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 F030A29392 for ; Wed, 25 May 2022 12:51:34 +0200 (CEST) Received: from yantan.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id ACEF55F6BD; Wed, 25 May 2022 10:51:26 +0000 (UTC) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by mail.notmuchmail.org (Postfix) with ESMTP id 6F1B55F701 for ; Wed, 25 May 2022 10:51:23 +0000 (UTC) Received: by fethera.tethera.net (Postfix, from userid 1001) id C9AFB5FC01; Wed, 25 May 2022 06:51:22 -0400 (EDT) Received: (nullmailer pid 10848 invoked by uid 1000); Wed, 25 May 2022 10:51:20 -0000 From: David Bremner To: notmuch@notmuchmail.org Subject: [PATCH 3/6] lib/tag: handle NULL argument to notmuch_tags_valid Date: Wed, 25 May 2022 07:51:14 -0300 Message-Id: <20220525105117.10709-4-david@tethera.net> X-Mailer: git-send-email 2.35.2 In-Reply-To: <20220525105117.10709-1-david@tethera.net> References: <20220525105117.10709-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: 5GS5YG2O6NL5LVJUNPRV5FKFS3URUWZI X-Message-ID-Hash: 5GS5YG2O6NL5LVJUNPRV5FKFS3URUWZI 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 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-To: larch@yhetil.org X-Migadu-Country: DE ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1653475895; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to: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=ojBKa12As+jpLPPVtxbGLE6Mi8rPRAAl2ROjR9uvGU0=; b=A+mDfC2euWd0TSLSjXRQCf56uiI5T2N31rxfboNkQlEtH5Ba8XGAfd2IknSXFHQ/1ccIn0 KarhV+oR0R/pVwHwlSWc5XUA3Im106dCXFyGYN0HrjoktvQV8BRcKTqWv0V4jj+hTfp78G GTvbEb0Kms2eN/XEkg1LgSyNcJLR/qFCszOzp0eY0AN3a4lv0ildRO7+Ra5Gc2SvYLRGmY FiOOIkuADIasCq2gk4eIyHUTmGzbYPLv8SnCR9GL/SeMvnCzJp2V0PsapRozMC+IZHtilK n8c6A7y1UoLfsZvNHfymZf5AnonKVZg47wXl/qzI4OO3liTQ9d3wnuDU26ZL/Q== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1653475895; a=rsa-sha256; cv=none; b=f+tOKUBJO+FladU5oDMn8eYzMQ/wqoWxJUHVmVMIkWMBtYZhecrc910kAgxZqcBcD4m1hk JOoSvo5B6nfNaLvOBtwcYo/Xt8VwkSu/IoIxxygRwlWOkB30KxrH2r2GGFrpfBeOjOii8C WQE3YwfJeuDY/7DXC4vZcIAyHRL3etdsN4YgIHg5fghlh5Aif0hrzt8D09GWqJ88BrD19B sQlNJtHwJZ9fLI2kLhw0TSwY+KBLAu7DesNlObY9c2DXNxi6Lg1E6KEsiy4X0wRMw7O600 rwUjLvslL5MfDiWHca0tza4t7oRKozYMwqOFYnyGX3VBUop9tQGbFPpgTZkmsQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 135.181.149.255 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -1.00 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 135.181.149.255 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: F030A29392 X-Spam-Score: -1.00 X-Migadu-Scanner: scn0.migadu.com X-TUID: yHDzYPCMzaHU Make the behaviour when passed NULL consistent with notmuch_filenames_valid. The library already passes the result of notmuch_message_get_tags without checking for NULL, so it should be handled. --- lib/notmuch.h | 3 +++ lib/tags.c | 2 +- test/T565-lib-tags.sh | 1 - 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/notmuch.h b/lib/notmuch.h index 2e6ec2af..44263a66 100644 --- a/lib/notmuch.h +++ b/lib/notmuch.h @@ -2262,6 +2262,9 @@ notmuch_message_properties_destroy (notmuch_message_properties_t *properties); * valid string. Whereas when this function returns FALSE, * notmuch_tags_get will return NULL. * + * It is acceptable to pass NULL for 'tags', in which case this + * function will always return FALSE. + * See the documentation of notmuch_message_get_tags for example code * showing how to iterate over a notmuch_tags_t object. */ diff --git a/lib/tags.c b/lib/tags.c index c7d3f66f..ec5366ff 100644 --- a/lib/tags.c +++ b/lib/tags.c @@ -48,7 +48,7 @@ _notmuch_tags_create (const void *ctx, notmuch_string_list_t *list) notmuch_bool_t notmuch_tags_valid (notmuch_tags_t *tags) { - return tags->iterator != NULL; + return tags && (tags->iterator != NULL); } const char * diff --git a/test/T565-lib-tags.sh b/test/T565-lib-tags.sh index 0f3595d2..2a59f8dd 100755 --- a/test/T565-lib-tags.sh +++ b/test/T565-lib-tags.sh @@ -68,7 +68,6 @@ test_expect_equal_file EXPECTED OUTPUT.clean restore_database test_begin_subtest "NULL tags are not valid" -test_subtest_known_broken cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} { notmuch_bool_t valid = TRUE; -- 2.35.2