[svn-commits] mnicholson: branch 1.4 r238629 - /branches/1.4/main/file.c
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Fri Jan 8 13:20:48 CST 2010
Author: mnicholson
Date: Fri Jan 8 13:20:44 2010
New Revision: 238629
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=238629
Log:
Properly calculate the remaining space in the output string when reducing format strings.
(closes issue #16560)
Reported by: goldwein
Modified:
branches/1.4/main/file.c
Modified: branches/1.4/main/file.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.4/main/file.c?view=diff&rev=238629&r1=238628&r2=238629
==============================================================================
--- branches/1.4/main/file.c (original)
+++ branches/1.4/main/file.c Fri Jan 8 13:20:44 2010
@@ -1367,6 +1367,7 @@
char *orig = fmts;
int i, j, x, first, found = 0;
int len = strlen(fmts) + 1;
+ int res;
if (AST_LIST_LOCK(&formats)) {
ast_log(LOG_WARNING, "Unable to lock format list\n");
@@ -1402,8 +1403,9 @@
/* special handling for the first entry */
if (first) {
- fmts += snprintf(fmts, len, "%s", fmts_str[i]);
- len -= (fmts - orig);
+ res = snprintf(fmts, len, "%s", fmts_str[i]);
+ fmts += res;
+ len -= res;
first = 0;
continue;
}
@@ -1418,8 +1420,9 @@
}
if (!found) {
- fmts += snprintf(fmts, len, "|%s", fmts_str[i]);
- len -= (fmts - orig);
+ res = snprintf(fmts, len, "|%s", fmts_str[i]);
+ fmts += res;
+ len -= res;
}
}
More information about the svn-commits
mailing list