diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c
index c372c1b91d..f552bbbdad 100644
--- a/libavcodec/flacdec.c
+++ b/libavcodec/flacdec.c
@@ -445,7 +445,7 @@ static inline int decode_subframe(FLACContext *s, int channel)
         return AVERROR_INVALIDDATA;
     }
 
-    if (wasted) {
+    if (wasted && wasted < 32) {
         int i;
         for (i = 0; i < s->blocksize; i++)
             decoded[i] = (unsigned)decoded[i] << wasted;