diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c
index e52d6f9b9fe5d8b0a758c1a3e89052b23cb238d2..813e41d6e3cedddc815d156648d00a6d6d46379a 100644
--- a/libavcodec/ffv1.c
+++ b/libavcodec/ffv1.c
@@ -1295,6 +1295,10 @@ static av_cold int common_end(AVCodecContext *avctx){
         av_freep(&s->rc_stat2[j]);
     }
 
+    for(i=0; i<s->slice_count; i++){
+        av_freep(&s->slice_context[i]);
+    }
+
     return 0;
 }