From b3720e9b10b580103dfa34b1104c2248e8a3c9e5 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 1 Aug 2008 16:00:55 +0000 Subject: [PATCH] fix endless loop in mod_expr git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9217 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/mod/applications/mod_expr/mod_expr.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/mod/applications/mod_expr/mod_expr.c b/src/mod/applications/mod_expr/mod_expr.c index e3573b6016..9500ded7d9 100644 --- a/src/mod/applications/mod_expr/mod_expr.c +++ b/src/mod/applications/mod_expr/mod_expr.c @@ -52,6 +52,7 @@ SWITCH_STANDARD_API(expr_function) char val[512] = "", *p; char *m_cmd = NULL; size_t len; + int ec = 0; if (switch_strlen_zero(cmd)) { goto error; @@ -126,7 +127,16 @@ SWITCH_STANDARD_API(expr_function) do { 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); for (p = (val + strlen(val) - 1); p != val; p--) {