From ae1e037d0c6f5df403cda7e1167860d726983339 Mon Sep 17 00:00:00 2001 From: James Booth Date: Sun, 19 Feb 2012 19:56:03 +0000 Subject: Tidy up roster loop --- jabber.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'jabber.c') diff --git a/jabber.c b/jabber.c index a0774c31..d55b56fd 100644 --- a/jabber.c +++ b/jabber.c @@ -193,10 +193,11 @@ static int _roster_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanz query = xmpp_stanza_get_child_by_name(stanza, "query"); cons_highlight_show("Roster:"); - for (item = xmpp_stanza_get_children(query); item; - item = xmpp_stanza_get_next(item)) { + item = xmpp_stanza_get_children(query); + while (item != NULL) { name = xmpp_stanza_get_attribute(item, "name"); jid = xmpp_stanza_get_attribute(item, "jid"); + if (name != NULL) { char line[2 + strlen(name) + 2 + strlen(jid) + 1 + 1]; sprintf(line, " %s (%s)", name, jid); @@ -207,6 +208,8 @@ static int _roster_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanz sprintf(line, " %s", jid); cons_show(line); } + + item = xmpp_stanza_get_next(item); } } -- cgit 1.4.1-2-gfad0