From efde1ab1385b4831313c20c227924e0a6ecb3208 Mon Sep 17 00:00:00 2001 From: Valentin Vidic <vvidic@valentin-vidic.from.hr> Date: Sun, 20 Jan 2019 19:15:51 +0100 Subject: [PATCH] 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: I1bae9126537be54895c7fea2d08dd9488d8cc525 --- main/channel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main/channel.c b/main/channel.c index 74d7986454..07b15212a8 100644 --- a/main/channel.c +++ b/main/channel.c @@ -5442,7 +5442,7 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr) if (jump >= 0) { jump = calc_monitor_jump((ast_channel_insmpl(chan) - ast_channel_outsmpl(chan)), ast_format_get_sample_rate(f->subclass.format), - ast_format_get_sample_rate(ast_channel_monitor(chan)->read_stream->fmt->format)); + ast_format_get_sample_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"); } @@ -5453,7 +5453,7 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr) #else int jump = calc_monitor_jump((ast_channel_insmpl(chan) - ast_channel_outsmpl(chan)), ast_format_get_sample_rate(f->subclass.format), - ast_format_get_sample_rate(ast_channel_monitor(chan)->read_stream->fmt->format)); + ast_format_get_sample_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"); -- GitLab