notmuch_tags_advance: Make safe against excessive calls.

Previously, an excess call would have caused a crash. Now it simply
does nothing. Also, make notmuch_tags_get use a similar, consistent
early return for a NULL iterator.
This commit is contained in:
Carl Worth 2009-11-14 23:02:55 -08:00
parent 322fe4f3fb
commit c979fc5b05

View file

@ -97,15 +97,18 @@ notmuch_tags_has_more (notmuch_tags_t *tags)
const char *
notmuch_tags_get (notmuch_tags_t *tags)
{
if (tags->iterator)
return (char *) tags->iterator->data;
else
if (tags->iterator == NULL)
return NULL;
return (char *) tags->iterator->data;
}
void
notmuch_tags_advance (notmuch_tags_t *tags)
{
if (tags->iterator == NULL)
return;
tags->iterator = tags->iterator->next;
}