[Asterisk-Dev] stable chan_skinny crash + fix
Vincent Sweeney
vince at quakenet.co.uk
Wed Feb 2 11:00:10 MST 2005
Hi.
Attached is a patch to fix a crash in the stable branch chan_skinny
module. I've had no time to see if the problems still exists in the
lastest HEAD version.
Anyway a situation can occur where sub->rtp is NULL and passed to
ast_rtp_read (BAD mmkay). No idea *why* it's NULL yet but the simple
patch is stable for me.
Vince.
-------------- next part --------------
diff -Nru asterisk/channels/chan_skinny.c asterisk.new/channels/chan_skinny.c
--- asterisk/channels/chan_skinny.c 2005-01-23 03:35:40.000000000 +0000
+++ asterisk.new/channels/chan_skinny.c 2005-02-01 16:06:14.517006556 +0000
@@ -1576,16 +1576,20 @@
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);
+ static struct ast_frame null_frame = { AST_FRAME_NULL, };
+ struct ast_frame *f = &null_frame;
+ 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);
+ }
}
}
}
More information about the asterisk-dev
mailing list