diff --git a/libavcodec/flacenc.c b/libavcodec/flacenc.c
index 8dd55eabe04f4320a233971ab448e9ee70e8408b..e2357affebb1ac5c38b47ebf1ec7187c05f14133 100644
--- a/libavcodec/flacenc.c
+++ b/libavcodec/flacenc.c
@@ -84,7 +84,7 @@ typedef struct FlacSubframe {
     int shift;
     RiceContext rc;
     int32_t samples[FLAC_MAX_BLOCKSIZE];
-    int32_t residual[FLAC_MAX_BLOCKSIZE];
+    int32_t residual[FLAC_MAX_BLOCKSIZE+1];
 } FlacSubframe;
 
 typedef struct FlacFrame {