[Asterisk-code-review] channel.c: Fix segfault with Monitor(wav,file,i) (asterisk[11])

Valentin Vidić asteriskteam at digium.com
Sun Jan 20 12:36:30 CST 2019


Valentin Vidić has uploaded this change for review. ( https://gerrit.asterisk.org/10894


Change subject: channel.c: Fix segfault with Monitor(wav,file,i)
......................................................................

channel.c: Fix segfault with Monitor(wav,file,i)

If the Monitor is started with the i option the read_stream will be
NULL. One code path in channel.c checks if write_stream is set but than
uses read_stream instead causing a segfault.

ASTERISK-28249

Change-Id: I18aac9ec6265da950c9e351101a15c2c04bba6ee
---
M main/channel.c
1 file changed, 2 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/94/10894/1

diff --git a/main/channel.c b/main/channel.c
index c5981d2..8b6b895 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -5194,7 +5194,7 @@
 #ifndef MONITOR_CONSTANT_DELAY
 				int jump = ast_channel_insmpl(chan) - ast_channel_outsmpl(chan) - 4 * cur->samples;
 				if (jump >= 0) {
-					jump = calc_monitor_jump((ast_channel_insmpl(chan) - ast_channel_outsmpl(chan)), ast_format_rate(&f->subclass.format), ast_format_rate(&ast_channel_monitor(chan)->read_stream->fmt->format));
+					jump = calc_monitor_jump((ast_channel_insmpl(chan) - ast_channel_outsmpl(chan)), ast_format_rate(&f->subclass.format), ast_format_rate(&ast_channel_monitor(chan)->write_stream->fmt->format));
 					if (ast_seekstream(ast_channel_monitor(chan)->write_stream, jump, SEEK_FORCECUR) == -1) {
 						ast_log(LOG_WARNING, "Failed to perform seek in monitoring write stream, synchronization between the files may be broken\n");
 					}
@@ -5203,7 +5203,7 @@
 					ast_channel_outsmpl_set(chan, ast_channel_outsmpl(chan) + cur->samples);
 				}
 #else
-				int jump = calc_monitor_jump((ast_channel_insmpl(chan) - ast_channel_outsmpl(chan)), ast_format_rate(f->subclass.codec), ast_format_rate(ast_channel_monitor(chan)->read_stream->fmt->format));
+				int jump = calc_monitor_jump((ast_channel_insmpl(chan) - ast_channel_outsmpl(chan)), ast_format_rate(f->subclass.codec), ast_format_rate(ast_channel_monitor(chan)->write_stream->fmt->format));
 				if (jump - MONITOR_DELAY >= 0) {
 					if (ast_seekstream(ast_channel_monitor(chan)->write_stream, jump - cur->samples, SEEK_FORCECUR) == -1) {
 						ast_log(LOG_WARNING, "Failed to perform seek in monitoring write stream, synchronization between the files may be broken\n");

-- 
To view, visit https://gerrit.asterisk.org/10894
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 11
Gerrit-MessageType: newchange
Gerrit-Change-Id: I18aac9ec6265da950c9e351101a15c2c04bba6ee
Gerrit-Change-Number: 10894
Gerrit-PatchSet: 1
Gerrit-Owner: Valentin Vidić <vvidic at valentin-vidic.from.hr>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20190120/7f9989e4/attachment.html>


More information about the asterisk-code-review mailing list