summaryrefslogtreecommitdiff
path: root/main/audiohook.c
diff options
context:
space:
mode:
authorJonathan Rose <jrose@digium.com>2015-12-02 14:11:08 -0600
committerJonathan Rose <jrose@digium.com>2015-12-03 15:31:28 -0600
commit69457b8d61ddc62e018dd4037fb42a231f73c3b5 (patch)
tree4af1406df8e8e0d575c98b0e73d2c6614a5fa21c /main/audiohook.c
parentb52b494004480ec7dfe33b762890ecf220b78f99 (diff)
Fix crash in audiohook translate to slin
This patch fixes a crash which would occur when an audiohook was applied to a channel using an audio codec that could not be translated to signed linear (such as when using pass-through codecs like OPUS or when the codec translator module for the format in use is not loaded). ASTERISK-25498 #close Reported by: Ben Langfeld Change-Id: Ib6ea7373fcc22e537cad373996136636201f4384
Diffstat (limited to 'main/audiohook.c')
-rw-r--r--main/audiohook.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/main/audiohook.c b/main/audiohook.c
index 73bb0ff11..e3089131e 100644
--- a/main/audiohook.c
+++ b/main/audiohook.c
@@ -824,13 +824,20 @@ static struct ast_frame *audiohook_list_translate_to_slin(struct ast_audiohook_l
return new_frame;
}
- if (ast_format_cmp(frame->subclass.format, in_translate->format) == AST_FORMAT_CMP_NOT_EQUAL) {
+ if (!in_translate->format ||
+ ast_format_cmp(frame->subclass.format, in_translate->format) != AST_FORMAT_CMP_EQUAL) {
+ struct ast_trans_pvt *new_trans;
+
+ new_trans = ast_translator_build_path(slin, frame->subclass.format);
+ if (!new_trans) {
+ return NULL;
+ }
+
if (in_translate->trans_pvt) {
ast_translator_free_path(in_translate->trans_pvt);
}
- if (!(in_translate->trans_pvt = ast_translator_build_path(slin, frame->subclass.format))) {
- return NULL;
- }
+ in_translate->trans_pvt = new_trans;
+
ao2_replace(in_translate->format, frame->subclass.format);
}