]> git.ipfire.org Git - thirdparty/freeswitch.git/commit
Fix mod_expr `clamp` function
authorTravis Cross <tc@traviscross.com>
Thu, 25 Dec 2014 10:11:47 +0000 (10:11 +0000)
committerTravis Cross <tc@traviscross.com>
Thu, 25 Dec 2014 10:18:31 +0000 (10:18 +0000)
commit65e678ba1d47c9e23c6a75268d4499b8a18f08b6
tree3a7c90be651557b2f9f2050f1a67c86367453850
parentd88bae1a62d44ef5e64b00c3fe6aad03d8f9faee
Fix mod_expr `clamp` function

The clamp(v,a,b) function wraps v around the interval [a,b).

However prior to this commit, `clamp` was ignoring the third argument
and using the second argument again in its place.  This resulted in a
division by zero.  Hence `clamp` didn't work at all.

Even if the arguments were treated correctly, `clamp` incorrectly
multiplied rather than added whenever v < a.  This would have produced
bogus results.  (Thanks to Shona McNeill for pointing this out.)

Note that as implemented, `clamp` is undefined for b >= a.

These errors are present in the last upstream C version, v2.7.
They've been corrected in the C++ version that upstream now maintains
instead.

Thanks-to: Shona McNeill <prufrax@googlemail.com>
FS-7070 #resolve
src/mod/applications/mod_expr/exprilfs.h