[Asterisk-cvs] asterisk/channels chan_iax2.c, 1.209, 1.210 chan_sip.c, 1.541, 1.542

citats at lists.digium.com citats at lists.digium.com
Sat Oct 23 02:59:02 CDT 2004


Update of /usr/cvsroot/asterisk/channels
In directory mongoose.digium.com:/tmp/cvs-serv30691/channels

Modified Files:
	chan_iax2.c chan_sip.c 
Log Message:
More memory checks

Index: chan_iax2.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_iax2.c,v
retrieving revision 1.209
retrieving revision 1.210
diff -u -d -r1.209 -r1.210
--- chan_iax2.c	22 Oct 2004 15:02:13 -0000	1.209
+++ chan_iax2.c	23 Oct 2004 07:03:01 -0000	1.210
@@ -6411,9 +6411,11 @@
  	} else {
 		ast_mutex_unlock(&peerl.lock);
 		peer = malloc(sizeof(struct iax2_peer));
-		memset(peer, 0, sizeof(struct iax2_peer));
-		peer->expire = -1;
-		peer->pokeexpire = -1;
+		if (peer) {
+			memset(peer, 0, sizeof(struct iax2_peer));
+			peer->expire = -1;
+			peer->pokeexpire = -1;
+		}
 	}
 	if (peer) {
 		peer->messagedetail = globalmessagedetail;
@@ -6589,7 +6591,8 @@
  	} else {
 		ast_mutex_unlock(&userl.lock);
 		user = malloc(sizeof(struct iax2_user));
-		memset(user, 0, sizeof(struct iax2_user));
+		if (user)
+			memset(user, 0, sizeof(struct iax2_user));
 	}
 	
 	if (user) {

Index: chan_sip.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_sip.c,v
retrieving revision 1.541
retrieving revision 1.542
diff -u -d -r1.541 -r1.542
--- chan_sip.c	22 Oct 2004 13:24:00 -0000	1.541
+++ chan_sip.c	23 Oct 2004 07:03:01 -0000	1.542
@@ -8164,6 +8164,8 @@
 {
 	struct sip_peer *peer;
 	peer = malloc(sizeof(struct sip_peer));
+	if (!peer)
+		return NULL;
 	memset(peer, 0, sizeof(struct sip_peer));
 	peer->expire = -1;
 	peer->pokeexpire = -1;
@@ -8228,12 +8230,14 @@
  	} else {
 		ast_mutex_unlock(&peerl.lock);
 		peer = malloc(sizeof(struct sip_peer));
-		memset(peer, 0, sizeof(struct sip_peer));
-		peer->expire = -1;
-		peer->pokeexpire = -1;
+		if (peer) {
+			memset(peer, 0, sizeof(struct sip_peer));
+			peer->expire = -1;
+			peer->pokeexpire = -1;
+		}
 	}
-	peer->lastmsgssent = -1;
 	if (peer) {
+		peer->lastmsgssent = -1;
 		if (!found) {
 			strncpy(peer->name, name, sizeof(peer->name)-1);
 			strncpy(peer->context, default_context, sizeof(peer->context)-1);




More information about the svn-commits mailing list