diff mbox series

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

Message ID HE1PR0301MB2154DCD33FA80546F5232C3B8F449@HE1PR0301MB2154.eurprd03.prod.outlook.com
State New
Headers show
Series [FFmpeg-devel,01/14] avcodec/ffv1dec: Remove redundant writes, fix races | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Andreas Rheinhardt April 24, 2021, 11:14 a.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/ffv1.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Michael Niedermayer April 25, 2021, 12:35 p.m. UTC | #1
On Sat, Apr 24, 2021 at 01:14:46PM +0200, Andreas Rheinhardt wrote:
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  libavcodec/ffv1.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)

LGTM

thx

[...]
diff mbox series

Patch

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++;