[FFmpeg-devel,03/11] avcodec/wavpackenc: Fix undefined shifts

Submitted by Andreas Rheinhardt on Sept. 19, 2019, 10:16 p.m.

Details

Message ID 20190919221706.16529-4-andreas.rheinhardt@gmail.com
State Accepted
Commit 84974c6fb542cf019904016c2165d9a62db9f312
Headers show

Commit Message

Andreas Rheinhardt Sept. 19, 2019, 10:16 p.m.
Fixes ticket #8161 and the acodec-wavpack FATE-test.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavcodec/wavpackenc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/libavcodec/wavpackenc.c b/libavcodec/wavpackenc.c
index 95f4b6530c..0c85fbe374 100644
--- a/libavcodec/wavpackenc.c
+++ b/libavcodec/wavpackenc.c
@@ -529,9 +529,9 @@  static int8_t store_weight(int weight)
 
 static int restore_weight(int8_t weight)
 {
-    int result;
+    int result = 8 * weight;
 
-    if ((result = (int) weight << 3) > 0)
+    if (result > 0)
         result += (result + 64) >> 7;
 
     return result;
@@ -2557,7 +2557,7 @@  static int wavpack_encode_block(WavPackEncodeContext *s,
             ret = wv_mono(s, samples_l, !s->num_terms, 1);
     } else {
         for (i = 0; i < nb_samples; i++)
-            crc += (crc << 3) + (samples_l[i] << 1) + samples_l[i] + samples_r[i];
+            crc += (crc << 3) + ((uint32_t)samples_l[i] << 1) + samples_l[i] + samples_r[i];
 
         if (s->num_passes)
             ret = wv_stereo(s, samples_l, samples_r, !s->num_terms, 1);