Skip to content
Snippets Groups Projects
Commit d6b56793 authored by Jean-Marc Valin's avatar Jean-Marc Valin
Browse files

Fixes a potential crash when encoding NaNs

This fixes tansig_approx() to avoid crashing when the input is NaN.
The problem could only be triggered when calling the float API with
a float build at a complexity of 7 or more (i.e. analysis called).
Since the crash was due to an out-of-bound read (typically the index
is INT_MIN), it's unlikely to be exploitable in any other way than
causing a crash.
parent e8f18c40
No related merge requests found
......@@ -67,9 +67,10 @@ static inline float tansig_approx(float x)
int i;
float y, dy;
float sign=1;
if (x>=8)
/* Tests are reversed to catch NaNs */
if (!(x<8))
return 1;
if (x<=-8)
if (!(x>-8))
return -1;
if (x<0)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment