wmadec: Fix left shift of negative value.
authorAndre Noll <maan@tuebingen.mpg.de>
Thu, 28 Apr 2016 19:57:13 +0000 (21:57 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Sun, 15 May 2016 10:14:20 +0000 (12:14 +0200)
gcc-6.1 complains about this:

wmadec_filter.c:819:33: warning: left shift of negative value [-Wshift-negative-value]
   mult1 = mult * exponents[((-1 << bsize)) >> esize];

The new code still looks wrong because we now shift a negative value
to the right. Moreover, it is not clear that the resulting value
is within array bounds. On the other hand, ffmpeg has the same fix
(commit a48b24e5 in the ffmpeg repository), so..

wmadec_filter.c

index be638ced7ad5e9d991ff109f7eaf5c68d4b800c3..0dff2b7914a0e1f1e18afc412bbd331bfe32f648 100644 (file)
@@ -810,7 +810,7 @@ static void compute_mdct_coefficients(struct private_wmadec_data *pwd,
                }
                /* very high freqs: noise */
                n = pwd->block_len - pwd->coefs_end[bsize];
-               mult1 = mult * exponents[((-1 << bsize)) >> esize];
+               mult1 = mult * exponents[(-(1 << bsize)) >> esize];
                for (i = 0; i < n; i++) {
                        *coefs++ = pwd->noise_table[pwd->noise_index] * mult1;
                        pwd->noise_index = (pwd->noise_index + 1)