From aafcf944989f9ad532180767af1e8cd0cfadb478 Mon Sep 17 00:00:00 2001
From: Paul B Mahol <onemda@gmail.com>
Date: Fri, 31 Jul 2020 09:42:47 +0200
Subject: [PATCH 3/3] avcodec/cfhd: fix non-aligned to 8 height decoding

---
 libavcodec/cfhd.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavcodec/cfhd.c b/libavcodec/cfhd.c
index 3d42e8ef4e..3c716579f8 100644
--- a/libavcodec/cfhd.c
+++ b/libavcodec/cfhd.c
@@ -310,16 +310,16 @@ static int alloc_buffers(AVCodecContext *avctx)
         s->plane[i].stride = stride;
 
         w8 = FFALIGN(s->plane[i].width  / 8, 8);
-        h8 = height / 8;
+        h8 = FFALIGN(height, 8) / 8;
         w4 = w8 * 2;
         h4 = h8 * 2;
         w2 = w4 * 2;
         h2 = h4 * 2;
 
         s->plane[i].idwt_buf =
-            av_mallocz_array(height * stride, sizeof(*s->plane[i].idwt_buf));
+            av_mallocz_array(FFALIGN(height, 8) * stride, sizeof(*s->plane[i].idwt_buf));
         s->plane[i].idwt_tmp =
-            av_malloc_array(height * stride, sizeof(*s->plane[i].idwt_tmp));
+            av_malloc_array(FFALIGN(height, 8) * stride, sizeof(*s->plane[i].idwt_tmp));
         if (!s->plane[i].idwt_buf || !s->plane[i].idwt_tmp)
             return AVERROR(ENOMEM);
 
-- 
2.26.2

