diff options
author | mnicholson <mnicholson@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-12-01 15:47:36 +0000 |
---|---|---|
committer | mnicholson <mnicholson@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-12-01 15:47:36 +0000 |
commit | 8837c685083d603ae72d8cfee90a2a22c2749128 (patch) | |
tree | 43dee1115c16c37bc286e02677537b2bf12c5cf8 /main/file.c | |
parent | 9b2fe661f936db3d2ee4906986818e9ff9cb3acc (diff) |
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: http://svn.digium.com/svn/asterisk/trunk@231741 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/file.c')
-rw-r--r-- | main/file.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/main/file.c b/main/file.c index 4885331e1..e9f078629 100644 --- a/main/file.c +++ b/main/file.c @@ -1354,7 +1354,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)) { @@ -1381,11 +1381,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; } @@ -1404,6 +1412,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; } |