diff options
author | Carl Worth <cworth@cworth.org> | 2009-11-14 23:02:55 -0800 |
---|---|---|
committer | Carl Worth <cworth@cworth.org> | 2009-11-14 23:02:55 -0800 |
commit | c979fc5b05a541d8488b77cbbc590ed3955690df (patch) | |
tree | c169dcc55e145746a8ef605835a44d59e16557c1 /lib/tags.c | |
parent | 322fe4f3fb6a547764715aecb4992f1c77547579 (diff) |
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.
Diffstat (limited to 'lib/tags.c')
-rw-r--r-- | lib/tags.c | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -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; } |