diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-04-30 04:23:09 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-04-30 04:23:09 +0000 |
commit | 5f70bde331b67ad1a780afe6c0c1268ae30fccc6 (patch) | |
tree | 70d555145fa53ae8a7a0740d3315e4eb131597f2 /pbx/pbx_dundi.c | |
parent | 211ac379f1227fb2cd5c26c49e2aadc3ecb786f2 (diff) |
immediately handle a memory allocation failure so the rest of the function
doesn't have to be indented (indentation still to be fixed)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@23464 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'pbx/pbx_dundi.c')
-rw-r--r-- | pbx/pbx_dundi.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/pbx/pbx_dundi.c b/pbx/pbx_dundi.c index f9481fe34..7fbdf5f41 100644 --- a/pbx/pbx_dundi.c +++ b/pbx/pbx_dundi.c @@ -4177,8 +4177,10 @@ static void build_peer(dundi_eid *eid, struct ast_variable *v, int *globalpcmode } if (!peer) { /* Add us into the list */ - peer = ast_calloc(1, sizeof(*peer)); - if (peer) { + if (!(peer = ast_calloc(1, sizeof(*peer)))) { + AST_LIST_UNLOCK(&peers); + return; + } peer->registerid = -1; peer->registerexpire = -1; peer->qualifyid = -1; @@ -4186,9 +4188,7 @@ static void build_peer(dundi_eid *eid, struct ast_variable *v, int *globalpcmode peer->addr.sin_port = htons(DUNDI_PORT); populate_addr(peer, eid); AST_LIST_INSERT_HEAD(&peers, peer, list); - } } - if (peer) { peer->dead = 0; peer->eid = *eid; peer->us_eid = global_eid; @@ -4308,7 +4308,6 @@ static void build_peer(dundi_eid *eid, struct ast_variable *v, int *globalpcmode } qualify_peer(peer, 1); } - } AST_LIST_UNLOCK(&peers); } |