summaryrefslogtreecommitdiffstats
path: root/libavutil/softfloat.h
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2015-11-08 14:13:42 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2015-11-08 14:54:51 +0100
commitcee3c9d29aceec8cddd829acd6dfb56dc5f60322 (patch)
tree8ee988fee729d7a5902a0e0c437169e1f47973a5 /libavutil/softfloat.h
parentdf2a2117d280a1579500034a8a3c79dc64b90c78 (diff)
downloadffmpeg-streaming-cee3c9d29aceec8cddd829acd6dfb56dc5f60322.zip
ffmpeg-streaming-cee3c9d29aceec8cddd829acd6dfb56dc5f60322.tar.gz
avutil/softfloat: Fix overflows in shifts in av_cmp_sf() and av_gt_sf()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavutil/softfloat.h')
-rw-r--r--libavutil/softfloat.h12
1 files changed, 8 insertions, 4 deletions
diff --git a/libavutil/softfloat.h b/libavutil/softfloat.h
index e5bfbbd..ae11bdb 100644
--- a/libavutil/softfloat.h
+++ b/libavutil/softfloat.h
@@ -119,15 +119,19 @@ static inline av_const SoftFloat av_div_sf(SoftFloat a, SoftFloat b){
static inline av_const int av_cmp_sf(SoftFloat a, SoftFloat b){
int t= a.exp - b.exp;
- if(t<0) return (a.mant >> (-t)) - b.mant ;
- else return a.mant - (b.mant >> t);
+ if (t <-31) return - b.mant ;
+ else if (t < 0) return (a.mant >> (-t)) - b.mant ;
+ else if (t < 32) return a.mant - (b.mant >> t);
+ else return a.mant ;
}
static inline av_const int av_gt_sf(SoftFloat a, SoftFloat b)
{
int t= a.exp - b.exp;
- if(t<0) return (a.mant >> (-t)) > b.mant ;
- else return a.mant > (b.mant >> t);
+ if (t <-31) return 0;
+ else if (t < 0) return (a.mant >> (-t)) > b.mant ;
+ else if (t < 32) return a.mant > (b.mant >> t);
+ else return 1;
}
static inline av_const SoftFloat av_add_sf(SoftFloat a, SoftFloat b){
OpenPOWER on IntegriCloud