]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Merged revisions 231741 via svnmerge from
authorMatthew Nicholson <mnicholson@digium.com>
Tue, 1 Dec 2009 15:48:49 +0000 (15:48 +0000)
committerMatthew Nicholson <mnicholson@digium.com>
Tue, 1 Dec 2009 15:48:49 +0000 (15:48 +0000)
https://origsvn.digium.com/svn/asterisk/trunk

................
  r231741 | mnicholson | 2009-12-01 09:47:36 -0600 (Tue, 01 Dec 2009) | 9 lines

  Merged revisions 231740 via svnmerge from
  https://origsvn.digium.com/svn/asterisk/branches/1.4

  ........
    r231740 | mnicholson | 2009-12-01 09:34:57 -0600 (Tue, 01 Dec 2009) | 2 lines

    Ignore unknown formats in ast_format_str_reduce() and return an error if no know formats are found.
  ........
................

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

main/file.c

index f35ff6fa39e8fd3e191a11f16b4cf29e095be3e3..1549b9d7bc8bef58164f334c87a100c295625d78 100644 (file)
@@ -1358,7 +1358,7 @@ char *ast_format_str_reduce(char *fmts)
        char *fmts_str[AST_MAX_FORMATS];
        char *stringp, *type;
        char *orig = fmts;
-       int i, j, x, found;
+       int i, j, x, first, found;
        int len = strlen(fmts) + 1;
 
        if (AST_RWLIST_RDLOCK(&formats)) {
@@ -1385,11 +1385,19 @@ char *ast_format_str_reduce(char *fmts)
        }
        AST_RWLIST_UNLOCK(&formats);
 
+       first = 1;
        for (i = 0; i < x; i++) {
+               /* ignore invalid entries */
+               if (!fmts_ptr[i]) {
+                       ast_log(LOG_WARNING, "ignoring unknown format '%s'\n", fmts_str[i]);
+                       continue;
+               }
+
                /* special handling for the first entry */
-               if (i == 0) {
+               if (first) {
                        fmts += snprintf(fmts, len, "%s", fmts_str[i]);
                        len -= (fmts - orig);
+                       first = 0;
                        continue;
                }
 
@@ -1408,6 +1416,11 @@ char *ast_format_str_reduce(char *fmts)
                }
        }
 
+       if (first) {
+               ast_log(LOG_WARNING, "no known formats found in format list (%s)\n", orig);
+               return NULL;
+       }
+
        return orig;
 }