From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 28E82431FBD for ; Fri, 24 Jan 2014 13:06:45 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id qo5D0XjJ7w2Z for ; Fri, 24 Jan 2014 13:06:35 -0800 (PST) Received: from mail-ee0-f53.google.com (mail-ee0-f53.google.com [74.125.83.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 5F85C431FB6 for ; Fri, 24 Jan 2014 13:06:35 -0800 (PST) Received: by mail-ee0-f53.google.com with SMTP id t10so1200353eei.40 for ; Fri, 24 Jan 2014 13:06:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:in-reply-to:references :user-agent:date:message-id:mime-version:content-type; bh=27KuWtQW9iXq95Ap/jKvQ9n/FMUT+QwrRFO+cEekh7U=; b=aM4wI8SQFipICTC+UOE3yYpCMbqG6BGoILfpNDPbzJWsyBjf/daxwUkadN3uza7QCn IRoVotL7lj8o9x7EEqVmYmgNaF9TPeMBF5tOXr/7PcXgU05W13bnO0+gexISEQzmkf6M vBRaotyiNFzLW45nwvtWeN52qouG3zyC8RMxK22iHVGVHPg80x0/pze1VmGFrnndM18U CKyLwPgVStr2ji+MjXNu7ZoXKc44VyqYQq8dD91C7fFvlnm1s796AJkB0aT1jr8R7haF rwLdp9C9pHQB0ziTueFykuQZ9RAPWQBfbVPeEnBW7GkeybaozEWPlJWt26cDsrY11MLW vgQg== X-Gm-Message-State: ALoCoQl6+kHBs7c6fV00yV14E6gPS4epRBPuS9RXdsLgJdJDENjStjeQl0JIJZlEBz0GXJaVAULi X-Received: by 10.14.100.71 with SMTP id y47mr4445636eef.91.1390597591326; Fri, 24 Jan 2014 13:06:31 -0800 (PST) Received: from localhost (dsl-hkibrasgw2-58c36f-91.dhcp.inet.fi. [88.195.111.91]) by mx.google.com with ESMTPSA id 8sm7860282eeq.15.2014.01.24.13.06.29 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 24 Jan 2014 13:06:30 -0800 (PST) From: Jani Nikula To: David Bremner , notmuch@notmuchmail.org Subject: Re: [PATCH 2/3] lib: make notmuch_threads_valid return FALSE when passed NULL In-Reply-To: <1390479841-17045-3-git-send-email-david@tethera.net> References: <1390479841-17045-1-git-send-email-david@tethera.net> <1390479841-17045-3-git-send-email-david@tethera.net> User-Agent: Notmuch/0.17+44~ge3b4cd9 (http://notmuchmail.org) Emacs/24.3.1 (x86_64-pc-linux-gnu) Date: Fri, 24 Jan 2014 23:06:28 +0200 Message-ID: <87wqhpf5t7.fsf@nikula.org> MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Jan 2014 21:06:45 -0000 On Thu, 23 Jan 2014, David Bremner wrote: > Without this patch, the example code in the header docs crashes for certain > invalid queries (see id:871u00oimv.fsf@approx.mit.edu) > --- > lib/notmuch.h | 2 ++ > lib/query.cc | 3 +++ > 2 files changed, 5 insertions(+) > > diff --git a/lib/notmuch.h b/lib/notmuch.h > index 02604c5..68896ae 100644 > --- a/lib/notmuch.h > +++ b/lib/notmuch.h > @@ -802,6 +802,8 @@ notmuch_query_destroy (notmuch_query_t *query); > * valid object. Whereas when this function returns FALSE, > * notmuch_threads_get will return NULL. > * > + * If passed a NULL pointer, this function returns FALSE > + * > * See the documentation of notmuch_query_search_threads for example > * code showing how to iterate over a notmuch_threads_t object. > */ > diff --git a/lib/query.cc b/lib/query.cc > index ec60e2e..60ff8bd 100644 > --- a/lib/query.cc > +++ b/lib/query.cc > @@ -462,6 +462,9 @@ notmuch_threads_valid (notmuch_threads_t *threads) > { > unsigned int doc_id; > > + if (! threads) > + return FALSE; > + LGTM, and this is in line with notmuch_messages_valid(). BR, Jani. > while (threads->doc_id_pos < threads->doc_ids->len) { > doc_id = g_array_index (threads->doc_ids, unsigned int, > threads->doc_id_pos); > -- > 1.8.5.2 > > _______________________________________________ > notmuch mailing list > notmuch@notmuchmail.org > http://notmuchmail.org/mailman/listinfo/notmuch