[FFmpeg-devel] [PATCH] alac: validate k before using show_bits in decode_scalar

Andreas Cadhalpun andreas.cadhalpun at googlemail.com
Wed Apr 22 18:24:54 CEST 2015


The k != 1 case calls show_bits(gb, k), which doesn't make sense if k
is 0.

Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun at googlemail.com>
---
 libavcodec/alac.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavcodec/alac.c b/libavcodec/alac.c
index ffd2d77..9db690b 100644
--- a/libavcodec/alac.c
+++ b/libavcodec/alac.c
@@ -90,6 +90,8 @@ static inline unsigned int decode_scalar(GetBitContext *gb, int k, int bps)
     if (x > 8) { /* RICE THRESHOLD */
         /* use alternative encoding */
         x = get_bits_long(gb, bps);
+    } else if (k <= 0) {
+        x = 0;
     } else if (k != 1) {
         int extrabits = show_bits(gb, k);
 
-- 
2.1.4


More information about the ffmpeg-devel mailing list