From 2b661bd1f414f2b962144e26418e130ae3d875be Mon Sep 17 00:00:00 2001 From: Dustin Sallings Date: Wed, 8 Apr 2009 14:03:46 -0700 Subject: [PATCH] Handle a case where the query has no namespace. When I tried this sample code, it failed due to a NULL namespace being returned (and a later strdup(NULL)). --- examples/bot.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/examples/bot.c b/examples/bot.c index e5bdeab..5dc0e70 100644 --- a/examples/bot.c +++ b/examples/bot.c @@ -29,6 +29,7 @@ int version_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, void * const userdata) { xmpp_stanza_t *reply, *query, *name, *version, *text; + char *ns; xmpp_ctx_t *ctx = (xmpp_ctx_t*)userdata; printf("Received version request from %s\n", xmpp_stanza_get_attribute(stanza, "from")); @@ -40,7 +41,10 @@ int version_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, void query = xmpp_stanza_new(ctx); xmpp_stanza_set_name(query, "query"); - xmpp_stanza_set_ns(query, xmpp_stanza_get_ns(xmpp_stanza_get_children(stanza))); + ns = xmpp_stanza_get_ns(xmpp_stanza_get_children(stanza)); + if (ns) { + xmpp_stanza_set_ns(query, ns); + } name = xmpp_stanza_new(ctx); xmpp_stanza_set_name(name, "name");