Don't pass NULL to strcmp()

There are places where code relies on well-formed stanzas and expects
that ns attribute is always present. Check whether ns NULL or not before
passing it to strcmp().

Fixes #121.
This commit is contained in:
Dmitry Podgorny
2018-07-30 20:38:43 +03:00
parent 0e6b0ef84d
commit a13ba65cfb
2 changed files with 25 additions and 13 deletions

View File

@@ -809,10 +809,11 @@ xmpp_stanza_t *xmpp_stanza_get_child_by_ns(xmpp_stanza_t * const stanza,
const char * const ns)
{
xmpp_stanza_t *child;
const char *child_ns;
for (child = stanza->children; child; child = child->next) {
if (xmpp_stanza_get_ns(child) &&
strcmp(ns, xmpp_stanza_get_ns(child)) == 0)
child_ns = xmpp_stanza_get_ns(child);
if (child_ns && strcmp(ns, child_ns) == 0)
break;
}