[Asterisk-code-review] Fix crash in audiohook translate to slin (asterisk[certified/13.1])

Jonathan Rose asteriskteam at digium.com
Thu Dec 3 16:04:47 CST 2015


Jonathan Rose has uploaded a new change for review.

  https://gerrit.asterisk.org/1760

Change subject: Fix crash in audiohook translate to slin
......................................................................

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
---
M main/audiohook.c
1 file changed, 11 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/60/1760/1

diff --git a/main/audiohook.c b/main/audiohook.c
index d1d0606..c810204 100644
--- a/main/audiohook.c
+++ b/main/audiohook.c
@@ -789,13 +789,20 @@
 		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);
 	}
 

-- 
To view, visit https://gerrit.asterisk.org/1760
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib6ea7373fcc22e537cad373996136636201f4384
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: certified/13.1
Gerrit-Owner: Jonathan Rose <jrose at digium.com>



More information about the asterisk-code-review mailing list