[FFmpeg-devel] [PATCH 14/14] avcodec/ffv1: Use av_memdup() instead of av_mallocz()+memcpy()

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Sat Apr 24 14:14:46 EEST 2021


Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
 libavcodec/ffv1.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c
index 8e7542f918..a5f5449602 100644
--- a/libavcodec/ffv1.c
+++ b/libavcodec/ffv1.c
@@ -120,19 +120,18 @@ av_cold int ff_ffv1_init_slice_contexts(FFV1Context *f)
     av_assert0(max_slice_count > 0);
 
     for (i = 0; i < max_slice_count;) {
+        FFV1Context *fs = av_memdup(f, sizeof(*fs));
         int sx          = i % f->num_h_slices;
         int sy          = i / f->num_h_slices;
         int sxs         = f->avctx->width  *  sx      / f->num_h_slices;
         int sxe         = f->avctx->width  * (sx + 1) / f->num_h_slices;
         int sys         = f->avctx->height *  sy      / f->num_v_slices;
         int sye         = f->avctx->height * (sy + 1) / f->num_v_slices;
-        FFV1Context *fs = av_mallocz(sizeof(*fs));
 
         if (!fs)
             goto memfail;
 
         f->slice_context[i] = fs;
-        memcpy(fs, f, sizeof(*fs));
         memset(fs->rc_stat2, 0, sizeof(fs->rc_stat2));
 
         fs->slice_index  = i++;
-- 
2.27.0



More information about the ffmpeg-devel mailing list