Notmuch was found to sometimes return a NULL when asked for a list of
tags. This caused mutt to crash when trying to autocomplete.
Thanks to William Pettersson (@WPettersson) for the initial patch.
Closes #393
Closes #395
*/
static void candidate (char *dest, char *try, const char *src, int len)
{
+ if (!dest || !try || !src)
+ return;
+
int l;
if (strstr (src, try) == src)
struct nm_ctxdata *data = get_ctxdata(ctx);
notmuch_database_t *db = NULL;
notmuch_tags_t *tags = NULL;
+ const char *tag;
int rc = -1;
if (!data)
while (notmuch_tags_valid(tags))
{
- if (tag_list != NULL)
+ tag = notmuch_tags_get(tags);
+ /* Skip empty string */
+ if (*tag)
{
- tag_list[*tag_count] = safe_strdup(notmuch_tags_get(tags));
+ if (tag_list != NULL)
+ tag_list[*tag_count] = safe_strdup(tag);
+ (*tag_count)++;
}
- (*tag_count)++;
notmuch_tags_move_to_next(tags);
}