[svn-commits] trunk r34667 - /trunk/res/res_jabber.c

svn-commits at lists.digium.com svn-commits at lists.digium.com
Sun Jun 18 14:45:48 MST 2006


Author: russell
Date: Sun Jun 18 16:45:48 2006
New Revision: 34667

URL: http://svn.digium.com/view/asterisk?rev=34667&view=rev
Log:
handle ast_calloc failure and tweak some formatting to comply with coding
guidelines (issue #7341, casper)

Modified:
    trunk/res/res_jabber.c

Modified: trunk/res/res_jabber.c
URL: http://svn.digium.com/view/asterisk/trunk/res/res_jabber.c?rev=34667&r1=34666&r2=34667&view=diff
==============================================================================
--- trunk/res/res_jabber.c (original)
+++ trunk/res/res_jabber.c Sun Jun 18 16:45:48 2006
@@ -1031,22 +1031,24 @@
 {
 	struct aji_message *insert, *tmp;
 	int flag = 0;
-	insert = ast_calloc(1,sizeof(struct aji_message));
+
+	if (!(insert = ast_calloc(1, sizeof(struct aji_message))))
+		return;
 	time(&insert->arrived);
 	insert->message = ast_strdup(iks_find_cdata(pak->x, "body"));
 	ast_copy_string(insert->id, pak->id, sizeof(insert->message));
 	insert->from = ast_strdup(pak->from->full);
 	AST_LIST_LOCK(&client->messages);
 	AST_LIST_TRAVERSE_SAFE_BEGIN(&client->messages, tmp, list) {
-		if(flag) {
-			AST_LIST_REMOVE_CURRENT(&client->messages,list);
+		if (flag) {
+			AST_LIST_REMOVE_CURRENT(&client->messages, list);
 			if (tmp->from)
 				free(tmp->from);
 			if (tmp->message)
 				free(tmp->message);
 		} else if (difftime(time(NULL), tmp->arrived) >= client->message_timeout) {
 			flag = 1;
-			AST_LIST_REMOVE_CURRENT(&client->messages,list);
+			AST_LIST_REMOVE_CURRENT(&client->messages, list);
 			if (tmp->from)
 				free(tmp->from);
 			if (tmp->message)
@@ -1054,9 +1056,10 @@
 		}
 	}
 	AST_LIST_TRAVERSE_SAFE_END;
-	AST_LIST_INSERT_HEAD(&client->messages,insert,list);
+	AST_LIST_INSERT_HEAD(&client->messages, insert, list);
 	AST_LIST_UNLOCK(&client->messages);
 }
+
 static void aji_handle_presence(struct aji_client *client, ikspak *pak)
 {
 	int status, priority;



More information about the svn-commits mailing list