avcodec/wavpack: Fix undefined integer negation
authorMichael Niedermayer <michael@niedermayer.cc>
Mon, 19 Jun 2017 12:08:58 +0000 (14:08 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Mon, 19 Jun 2017 15:54:40 +0000 (17:54 +0200)
Fixes: runtime error: negation of -2147483648 cannot be represented in type 'int'; cast to an unsigned type to negate this value to itself
Fixes: 2291/clusterfuzz-testcase-minimized-5538453481586688

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

index 6e601f0..ac43c13 100644 (file)
@@ -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