[Asterisk-cvs] asterisk/channels chan_skinny.c,1.54.2.1,1.54.2.2

russell at lists.digium.com russell at lists.digium.com
Wed Mar 2 16:35:40 CST 2005


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

Modified Files:
      Tag: v1-0
	chan_skinny.c 
Log Message:
add a check to prevent a seg fault from an unknown cause ... (bug #3496)


Index: chan_skinny.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_skinny.c,v
retrieving revision 1.54.2.1
retrieving revision 1.54.2.2
diff -u -d -r1.54.2.1 -r1.54.2.2
--- chan_skinny.c	17 Jan 2005 00:37:22 -0000	1.54.2.1
+++ chan_skinny.c	2 Mar 2005 22:32:57 -0000	1.54.2.2
@@ -1576,19 +1576,22 @@
 static struct ast_frame *skinny_rtp_read(struct skinny_subchannel *sub)
 {
 	/* Retrieve audio/etc from channel.  Assumes sub->lock is already held. */
-	struct ast_frame *f;
-	f = ast_rtp_read(sub->rtp);
-	if (sub->owner) {
-		/* We already hold the channel lock */
-		if (f->frametype == AST_FRAME_VOICE) {
-			if (f->subclass != sub->owner->nativeformats) {
-				ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass);
-				sub->owner->nativeformats = f->subclass;
-				ast_set_read_format(sub->owner, sub->owner->readformat);
-				ast_set_write_format(sub->owner, sub->owner->writeformat);
+	struct ast_frame *f = NULL;
+	if (sub->rtp) {	
+		f = ast_rtp_read(sub->rtp);
+		if (sub->owner) {
+			/* We already hold the channel lock */
+			if (f->frametype == AST_FRAME_VOICE) {
+				if (f->subclass != sub->owner->nativeformats) {
+					ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass);
+					sub->owner->nativeformats = f->subclass;
+					ast_set_read_format(sub->owner, sub->owner->readformat);
+					ast_set_write_format(sub->owner, sub->owner->writeformat);
+				}
 			}
 		}
-	}
+	} else
+		ast_log(LOG_WARNING, "sub->rtp is NULL - calling read on a channel that has been hungup?\n");
 	return f;
 }
 




More information about the svn-commits mailing list