fix a potential segfault
authorMatt O'Gorman <mogorman@digium.com>
Tue, 6 Jun 2006 19:18:44 +0000 (19:18 +0000)
committerMatt O'Gorman <mogorman@digium.com>
Tue, 6 Jun 2006 19:18:44 +0000 (19:18 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@32674 65c4cc65-6c06-0410-ace0-fbb531ad65f3

res/res_jabber.c

index 6b516d4..8a16ade 100644 (file)
@@ -811,7 +811,11 @@ static int aji_client_info_handler(void *data, ikspak *pak)
        buddy = ASTOBJ_CONTAINER_FIND(&client->buddies, pak->from->partial);
 
        resource = aji_find_resource(buddy, pak->from->resource);
-
+       if (!resource) {
+               ast_log(LOG_NOTICE,"JABBER: Received client info from %s when not requested.\n", pak->from->full);
+               ASTOBJ_UNREF(client, aji_client_destroy);
+               return IKS_FILTER_EAT;
+       }       
        if (pak->subtype == IKS_TYPE_RESULT) {
                if (iks_find_with_attrib(pak->query, "feature", "var", "http://www.google.com/xmpp/protocol/voice/v1")) {
                        resource->cap->jingle = 1;
@@ -837,8 +841,8 @@ static int aji_client_info_handler(void *data, ikspak *pak)
                        iks_insert_attrib(google, "var", "http://www.google.com/xmpp/protocol/voice/v1");
                        iks_insert_node(iq, query);
                        iks_insert_node(query, ident);
-                       iks_insert_node(query, disco);
                        iks_insert_node(query, google);
+                       iks_insert_node(query, disco);
                        iks_send(client->p, iq);
                } else
                        ast_log(LOG_ERROR, "Out of Memory.\n");