]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/wavpack.c
Merge commit '7208e5b5d638d4b9c2784036b4fc5728f32233c7'
[ffmpeg] / libavcodec / wavpack.c
index b216eb068352c06d5cf75a4047c5f6c1c9b33225..a117e8aa81ba2ee4b9d223bfd84ddac603cdc48e 100644 (file)
@@ -188,7 +188,7 @@ static int wv_get_value(WavpackFrameContext *ctx, GetBitContext *gb,
                     goto error;
                 t += t2;
             } else {
-                if (get_bits_left(gb) < t2 - 1)
+                if (t2 >= 32 || get_bits_left(gb) < t2 - 1)
                     goto error;
                 t += get_bits_long(gb, t2 - 1) | (1 << (t2 - 1));
             }
@@ -225,7 +225,7 @@ static int wv_get_value(WavpackFrameContext *ctx, GetBitContext *gb,
         INC_MED(1);
         DEC_MED(2);
     } else {
-        base = GET_MED(0) + GET_MED(1) + GET_MED(2) * (t - 2);
+        base = GET_MED(0) + GET_MED(1) + GET_MED(2) * (t - 2U);
         add  = GET_MED(2) - 1;
         INC_MED(0);
         INC_MED(1);
@@ -248,7 +248,7 @@ static int wv_get_value(WavpackFrameContext *ctx, GetBitContext *gb,
                 add -= (mid - (unsigned)base);
                 base = mid;
             } else
-                add = mid - base - 1;
+                add = mid - (unsigned)base - 1;
             mid = (base * 2U + add + 1) >> 1;
         }
         ret = mid;
@@ -313,8 +313,8 @@ static float wv_get_value_float(WavpackFrameContext *s, uint32_t *crc, int S)
         S  *= 1U << s->float_shift;
         sign = S < 0;
         if (sign)
-            S = -S;
-        if (S >= 0x1000000) {
+            S = -(unsigned)S;
+        if (S >= 0x1000000U) {
             if (s->got_extra_bits && get_bits1(&s->gb_extra_bits))
                 S = get_bits(&s->gb_extra_bits, 23);
             else
@@ -480,7 +480,7 @@ static inline int wv_unpack_stereo(WavpackFrameContext *s, GetBitContext *gb,
         }
 
         if (type == AV_SAMPLE_FMT_S16P) {
-            if (FFABS(L) + FFABS(R) > (1<<19)) {
+            if (FFABS(L) + (unsigned)FFABS(R) > (1<<19)) {
                 av_log(s->avctx, AV_LOG_ERROR, "sample %d %d too large\n", L, R);
                 return AVERROR_INVALIDDATA;
             }
@@ -846,9 +846,9 @@ static int wavpack_decode_block(AVCodecContext *avctx, int block_no,
                 continue;
             }
             bytestream2_get_buffer(&gb, val, 4);
-            if (val[0] > 31) {
+            if (val[0] > 30) {
                 av_log(avctx, AV_LOG_ERROR,
-                       "Invalid INT32INFO, extra_bits = %d (> 32)\n", val[0]);
+                       "Invalid INT32INFO, extra_bits = %d (> 30)\n", val[0]);
                 continue;
             } else if (val[0]) {
                 s->extra_bits = val[0];