[svn-commits] tilghman: branch 1.4 r135915 - /branches/1.4/main/translate.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Aug 5 22:24:57 CDT 2008


Author: tilghman
Date: Tue Aug  5 22:24:56 2008
New Revision: 135915

URL: http://svn.digium.com/view/asterisk?view=rev&rev=135915
Log:
Since powerof() can return an error condition, it's foolhardy not to detect and
deal with that condition.
(Related to issue #13240)

Modified:
    branches/1.4/main/translate.c

Modified: branches/1.4/main/translate.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/main/translate.c?view=diff&rev=135915&r1=135914&r2=135915
==============================================================================
--- branches/1.4/main/translate.c (original)
+++ branches/1.4/main/translate.c Tue Aug  5 22:24:56 2008
@@ -273,7 +273,12 @@
 	
 	source = powerof(source);
 	dest = powerof(dest);
-	
+
+	if (source == -1 || dest == -1) {
+		ast_log(LOG_WARNING, "No translator path: (%s codec is not valid)\n", source == -1 ? "starting" : "ending");
+		return NULL;
+	}
+
 	AST_LIST_LOCK(&translators);
 
 	while (source != dest) {
@@ -694,6 +699,10 @@
 	t->dstfmt = powerof(t->dstfmt);
 	t->active = 1;
 
+	if (t->srcfmt == -1 || t->dstfmt == -1) {
+		ast_log(LOG_WARNING, "Invalid translator path: (%s codec is not valid)\n", t->srcfmt == -1 ? "starting" : "ending");
+		return -1;
+	}
 	if (t->plc_samples) {
 		if (t->buffer_samples < t->plc_samples) {
 			ast_log(LOG_WARNING, "plc_samples %d buffer_samples %d\n",
@@ -868,6 +877,10 @@
 	src = powerof(src);
 	dest = powerof(dest);
 
+	if (src == -1 || dest == -1) {
+		ast_log(LOG_WARNING, "No translator path: (%s codec is not valid)\n", src == -1 ? "starting" : "ending");
+		return -1;
+	}
 	AST_LIST_LOCK(&translators);
 
 	if (tr_matrix[src][dest].step)




More information about the svn-commits mailing list