summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Colp <jcolp@digium.com>2017-11-02 07:34:46 -0300
committerJoshua Colp <jcolp@digium.com>2017-11-02 05:37:48 -0500
commit87014793863199b158e3226030c7a13e907f8c8a (patch)
treefd3287d8c1485c69ebda1ade098492bf6f9a660a
parent64f1294ef2c799cda27ee83258fc5567a274bb34 (diff)
core: Don't attempt to write to a stream that does not exist.
When a frame is provided to ast_write ensure that a multistream capable channel has a stream for it before attempting to give it to the channel driver. In some cases (such as a deferred SDP negotiation) the stream may not yet exist. ASTERISK-27364 Change-Id: Icf84ca982a67cdd6e9a71851eb7eb1bd0e865276
-rw-r--r--main/channel.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/main/channel.c b/main/channel.c
index 7d6e5db07..7eb40d195 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -5054,7 +5054,11 @@ int ast_write_stream(struct ast_channel *chan, int stream_num, struct ast_frame
case AST_FRAME_VIDEO:
/* XXX Handle translation of video codecs one day XXX */
if (ast_channel_tech(chan)->write_stream) {
- res = ast_channel_tech(chan)->write_stream(chan, ast_stream_get_position(stream), fr);
+ if (stream) {
+ res = ast_channel_tech(chan)->write_stream(chan, ast_stream_get_position(stream), fr);
+ } else {
+ res = 0;
+ }
} else if ((stream == default_stream) && ast_channel_tech(chan)->write_video) {
res = ast_channel_tech(chan)->write_video(chan, fr);
} else {
@@ -5063,7 +5067,11 @@ int ast_write_stream(struct ast_channel *chan, int stream_num, struct ast_frame
break;
case AST_FRAME_MODEM:
if (ast_channel_tech(chan)->write_stream) {
- res = ast_channel_tech(chan)->write_stream(chan, ast_stream_get_position(stream), fr);
+ if (stream) {
+ res = ast_channel_tech(chan)->write_stream(chan, ast_stream_get_position(stream), fr);
+ } else {
+ res = 0;
+ }
} else if ((stream == default_stream) && ast_channel_tech(chan)->write) {
res = ast_channel_tech(chan)->write(chan, fr);
} else {
@@ -5251,7 +5259,11 @@ int ast_write_stream(struct ast_channel *chan, int stream_num, struct ast_frame
f = NULL;
} else {
if (ast_channel_tech(chan)->write_stream) {
- res = ast_channel_tech(chan)->write_stream(chan, ast_stream_get_position(stream), f);
+ if (stream) {
+ res = ast_channel_tech(chan)->write_stream(chan, ast_stream_get_position(stream), f);
+ } else {
+ res = 0;
+ }
} else if ((stream == default_stream) && ast_channel_tech(chan)->write) {
res = ast_channel_tech(chan)->write(chan, f);
} else {