diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c
index 73e524a55dec2b078103fcf048e35243da7f8a7b..ab2be93442d82bd92878e1e1f9aa1102436e1055 100644
--- a/libavcodec/flacdec.c
+++ b/libavcodec/flacdec.c
@@ -545,7 +545,7 @@ static int decode_frame(FLACContext *s, int alloc_data_size)
         return -1;
     }
 
-    if (blocksize * s->channels * sizeof(int16_t) > alloc_data_size)
+    if (blocksize * s->channels * (s->is32 ? 4 : 2) > alloc_data_size)
         return -1;
 
     if (sample_rate_code == 0)