From: Russell Bryant Date: Wed, 2 Mar 2005 22:32:57 +0000 (+0000) Subject: add a check to prevent a seg fault from an unknown cause ... (bug #3496) X-Git-Tag: 1.0.11.1~202 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fd7f18421d148c46d39ca32983e423198e007a2f;p=thirdparty%2Fasterisk.git add a check to prevent a seg fault from an unknown cause ... (bug #3496) git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/v1-0@5122 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c index 920899664f..3b18955c87 100755 --- a/channels/chan_skinny.c +++ b/channels/chan_skinny.c @@ -1576,19 +1576,22 @@ static int skinny_answer(struct ast_channel *ast) 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; }