summaryrefslogtreecommitdiff
path: root/res
diff options
context:
space:
mode:
authorRussell Bryant <russell@russellbryant.com>2006-06-18 21:45:48 +0000
committerRussell Bryant <russell@russellbryant.com>2006-06-18 21:45:48 +0000
commit5288621ed42f996ed3446f00608665abfb91adf0 (patch)
tree3ece6bbbe253c1c5f4a1fdf1454567082be00134 /res
parent73ae55698fdc5ffc2a0f0d8c4a499cd9b09dc562 (diff)
handle ast_calloc failure and tweak some formatting to comply with coding
guidelines (issue #7341, casper) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@34667 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res')
-rw-r--r--res/res_jabber.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/res/res_jabber.c b/res/res_jabber.c
index b20899d74..aa0f856da 100644
--- a/res/res_jabber.c
+++ b/res/res_jabber.c
@@ -1031,22 +1031,24 @@ static void aji_handle_message(struct aji_client *client, ikspak *pak)
{
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 @@ static void aji_handle_message(struct aji_client *client, ikspak *pak)
}
}
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;