From: Carl Worth Date: Sun, 15 Nov 2009 07:02:55 +0000 (-0800) Subject: notmuch_tags_advance: Make safe against excessive calls. X-Git-Tag: 0.1~498 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=c979fc5b05a541d8488b77cbbc590ed3955690df;p=notmuch.git 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. --- diff --git a/lib/tags.c b/lib/tags.c index afc132c5..85507e91 100644 --- a/lib/tags.c +++ b/lib/tags.c @@ -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; }