fix endless loop in mod_expr

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9217 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2008-08-01 16:00:55 +00:00
parent d8816f7d73
commit b3720e9b10
1 changed files with 11 additions and 1 deletions

View File

@ -52,6 +52,7 @@ SWITCH_STANDARD_API(expr_function)
char val[512] = "", *p; char val[512] = "", *p;
char *m_cmd = NULL; char *m_cmd = NULL;
size_t len; size_t len;
int ec = 0;
if (switch_strlen_zero(cmd)) { if (switch_strlen_zero(cmd)) {
goto error; goto error;
@ -126,7 +127,16 @@ SWITCH_STANDARD_API(expr_function)
do { do {
err = exprEval(e, &last_expr); err = exprEval(e, &last_expr);
} while (err); if (err) {
ec++;
} else {
ec = 0;
}
} while (err && ec < 3);
if (err) {
goto error;
}
switch_snprintf(val, sizeof(val), "%0.10f", last_expr); switch_snprintf(val, sizeof(val), "%0.10f", last_expr);
for (p = (val + strlen(val) - 1); p != val; p--) { for (p = (val + strlen(val) - 1); p != val; p--) {