[asterisk-commits] trunk r23464 - /trunk/pbx/pbx_dundi.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Sat Apr 29 21:23:10 MST 2006


Author: russell
Date: Sat Apr 29 23:23:09 2006
New Revision: 23464

URL: http://svn.digium.com/view/asterisk?rev=23464&view=rev
Log:
immediately handle a memory allocation failure so the rest of the function
doesn't have to be indented (indentation still to be fixed)

Modified:
    trunk/pbx/pbx_dundi.c

Modified: trunk/pbx/pbx_dundi.c
URL: http://svn.digium.com/view/asterisk/trunk/pbx/pbx_dundi.c?rev=23464&r1=23463&r2=23464&view=diff
==============================================================================
--- trunk/pbx/pbx_dundi.c (original)
+++ trunk/pbx/pbx_dundi.c Sat Apr 29 23:23:09 2006
@@ -4177,8 +4177,10 @@
 	}
 	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 @@
 			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 @@
 			}
 			qualify_peer(peer, 1);
 		}
-	}
 	AST_LIST_UNLOCK(&peers);
 }
 



More information about the asterisk-commits mailing list