]> git.notmuchmail.org Git - notmuch/commitdiff
lib: Fix notmuch_query_search_threads to return NULL on any Xapian exception.
authorCarl Worth <cworth@cworth.org>
Sat, 23 Oct 2010 00:55:07 +0000 (17:55 -0700)
committerCarl Worth <cworth@cworth.org>
Sat, 23 Oct 2010 00:56:58 +0000 (17:56 -0700)
Previously, if the underlying search_messages hit an exception and returned
NULL, this function would ignore that and return a non-NULL, (but empty)
threads object. Fix this to properly propagate the error.

lib/notmuch.h
lib/query.cc

index 505ad19fe90470c958fa9d59805af929b588af8e..9a19699956dc0a9178d6f0fc39110e0ee7acf92d 100644 (file)
@@ -400,6 +400,8 @@ notmuch_query_set_sort (notmuch_query_t *query, notmuch_sort_t sort);
  * notmuch_threads_t object. (For consistency, we do provide a
  * notmuch_threads_destroy function, but there's no good reason
  * to call it if the query is about to be destroyed).
+ *
+ * If a Xapian exception occurs this function will return NULL.
  */
 notmuch_threads_t *
 notmuch_query_search_threads (notmuch_query_t *query);
index d241dc1dc819a6246e2bfc791330c5448dc9548e..59f4011b31d3a3f5616227d352b8f7234b05ee0f 100644 (file)
@@ -249,6 +249,10 @@ notmuch_query_search_threads (notmuch_query_t *query)
                                              free, NULL);
 
     threads->messages = notmuch_query_search_messages (query);
+    if (threads->messages == NULL) {
+           talloc_free (threads);
+           return NULL;
+    }
 
     threads->thread_id = NULL;