]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Merged revisions 135915 via svnmerge from
authorTilghman Lesher <tilghman@meg.abyt.es>
Wed, 6 Aug 2008 03:29:42 +0000 (03:29 +0000)
committerTilghman Lesher <tilghman@meg.abyt.es>
Wed, 6 Aug 2008 03:29:42 +0000 (03:29 +0000)
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r135915 | tilghman | 2008-08-05 22:24:56 -0500 (Tue, 05 Aug 2008) | 4 lines

Since powerof() can return an error condition, it's foolhardy not to detect and
deal with that condition.
(Related to issue #13240)

........

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@135938 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/translate.c

index 4ee94d940e3644ac27fa76ca7d5578f7fa6b3d37..96d67bc9285064421f5c8608fb3cae2615319bab 100644 (file)
@@ -265,7 +265,12 @@ struct ast_trans_pvt *ast_translator_build_path(int dest, int source)
        
        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_RWLIST_RDLOCK(&translators);
 
        while (source != dest) {
@@ -625,6 +630,10 @@ int __ast_register_translator(struct ast_translator *t, struct ast_module *mod)
        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",
@@ -794,6 +803,10 @@ unsigned int ast_translate_path_steps(unsigned int dest, unsigned int src)
        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_RWLIST_RDLOCK(&translators);
 
        if (tr_matrix[src][dest].step)