avcodec/mpegaudiodec_template: Make l3_unscale() work with e=0
authorMichael Niedermayer <michael@niedermayer.cc>
Mon, 13 Mar 2017 19:45:09 +0000 (20:45 +0100)
committerMichael Niedermayer <michael@niedermayer.cc>
Tue, 14 Mar 2017 21:48:49 +0000 (22:48 +0100)
Fixes undefined behavior
Fixes: 830/clusterfuzz-testcase-6253175327686656

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/mpegaudiodec_template.c

index 88f6272..a5ac581 100644 (file)
@@ -253,7 +253,7 @@ static inline int l3_unscale(int value, int exponent)
 #endif
     if (e > (SUINT)31)
         return 0;
-    m = (m + (1 << (e - 1))) >> e;
+    m = (m + ((1U << e)>>1)) >> e;
 
     return m;
 }