]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Fix crash in audiohook translate to slin 62/1762/1
authorJoshua Colp <jcolp@digium.com>
Fri, 4 Dec 2015 14:15:24 +0000 (10:15 -0400)
committerJoshua Colp <jcolp@digium.com>
Fri, 4 Dec 2015 14:15:24 +0000 (10:15 -0400)
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

main/audiohook.c

index c1df580df321c519fc0ddae3638b6b89e2a7dcbc..f9c0abe51c74d63e1744c2fb17fb42dd04d4354d 100644 (file)
@@ -765,12 +765,18 @@ static struct ast_frame *audiohook_list_translate_to_slin(struct ast_audiohook_l
        }
 
        if (ast_format_cmp(&frame->subclass.format, &in_translate->format) == AST_FORMAT_CMP_NOT_EQUAL) {
+               struct ast_trans_pvt *new_trans;
+
+               new_trans = ast_translator_build_path(ast_format_set(&tmp_fmt, slin_id, 0), &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(ast_format_set(&tmp_fmt, slin_id, 0), &frame->subclass.format))) {
-                       return NULL;
-               }
+               in_translate->trans_pvt = new_trans;
+
                ast_format_copy(&in_translate->format, &frame->subclass.format);
        }
        if (!(new_frame = ast_translate(in_translate->trans_pvt, frame, 0))) {