mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-22 02:48:08 +01:00
lib: Ensure notmuch_query_search_messages returns NULL on an exception.
Previously, this function may have segfaulted immediately after reporting the exception.
This commit is contained in:
parent
e3e0e26806
commit
138fd38afe
2 changed files with 6 additions and 2 deletions
|
@ -439,6 +439,8 @@ notmuch_query_search_threads (notmuch_query_t *query);
|
|||
* notmuch_messages_t object. (For consistency, we do provide a
|
||||
* notmuch_messages_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_messages_t *
|
||||
notmuch_query_search_messages (notmuch_query_t *query);
|
||||
|
|
|
@ -163,14 +163,16 @@ notmuch_query_search_messages (notmuch_query_t *query)
|
|||
messages->iterator = mset.begin ();
|
||||
messages->iterator_end = mset.end ();
|
||||
|
||||
return &messages->base;
|
||||
|
||||
} catch (const Xapian::Error &error) {
|
||||
fprintf (stderr, "A Xapian exception occurred performing query: %s\n",
|
||||
error.get_msg().c_str());
|
||||
fprintf (stderr, "Query string was: %s\n", query->query_string);
|
||||
notmuch->exception_reported = TRUE;
|
||||
talloc_free (messages);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return &messages->base;
|
||||
}
|
||||
|
||||
notmuch_bool_t
|
||||
|
|
Loading…
Reference in a new issue