softfloat: assert when the argument of av_sqrt_sf is negative
authorAndreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Sun, 8 Nov 2015 14:15:24 +0000 (15:15 +0100)
committerAndreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Sun, 8 Nov 2015 20:05:21 +0000 (21:05 +0100)
The correct result can't be expressed in SoftFloat.
Currently it returns a random value from an out of bounds read.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
libavutil/softfloat.h

index 651bbf4..4cc3ceb 100644 (file)
@@ -174,6 +174,8 @@ static av_always_inline SoftFloat av_sqrt_sf(SoftFloat val)
 
     if (val.mant == 0)
         val.exp = MIN_EXP;
+    else if (val.mant < 0)
+        av_assert0(0);
     else
     {
         tabIndex = (val.mant - 0x20000000) >> 20;