diff mbox series

[FFmpeg-devel,4/4] avformat/mxfdec: Do not clear array in mxf_read_strong_ref_array() before writing

Message ID 20220312235227.19626-4-michael@niedermayer.cc
State New
Headers show
Series [FFmpeg-devel,1/4] avcodec/vp9_superframe_split_bsf: Check in size | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_aarch64_jetson success Make finished
andriy/make_fate_aarch64_jetson success Make fate finished
andriy/make_armv7_RPi4 success Make finished
andriy/make_fate_armv7_RPi4 success Make fate finished

Commit Message

Michael Niedermayer March 12, 2022, 11:52 p.m. UTC
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavformat/mxfdec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Marton Balint March 13, 2022, 3:53 p.m. UTC | #1
On Sun, 13 Mar 2022, Michael Niedermayer wrote:

> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
> libavformat/mxfdec.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
> index 828fc0f9f1..f088712494 100644
> --- a/libavformat/mxfdec.c
> +++ b/libavformat/mxfdec.c
> @@ -941,7 +941,7 @@ static int mxf_read_strong_ref_array(AVIOContext *pb, UID **refs, int *count)
>     *count = c;
>
>     av_free(*refs);
> -    *refs = av_calloc(*count, sizeof(UID));
> +    *refs = av_malloc(*count * sizeof(UID));

I suggest av_malloc_array(), even if it can't overflow because of earlier 
checks.

Thanks,
Marton

>     if (!*refs) {
>         *count = 0;
>         return AVERROR(ENOMEM);
> -- 
> 2.17.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
Michael Niedermayer March 14, 2022, 1:59 p.m. UTC | #2
On Sun, Mar 13, 2022 at 04:53:29PM +0100, Marton Balint wrote:
> 
> 
> On Sun, 13 Mar 2022, Michael Niedermayer wrote:
> 
> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > ---
> > libavformat/mxfdec.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
> > index 828fc0f9f1..f088712494 100644
> > --- a/libavformat/mxfdec.c
> > +++ b/libavformat/mxfdec.c
> > @@ -941,7 +941,7 @@ static int mxf_read_strong_ref_array(AVIOContext *pb, UID **refs, int *count)
> >     *count = c;
> > 
> >     av_free(*refs);
> > -    *refs = av_calloc(*count, sizeof(UID));
> > +    *refs = av_malloc(*count * sizeof(UID));
> 
> I suggest av_malloc_array(), even if it can't overflow because of earlier
> checks.

agree, will change that

thx

[...]
diff mbox series

Patch

diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 828fc0f9f1..f088712494 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -941,7 +941,7 @@  static int mxf_read_strong_ref_array(AVIOContext *pb, UID **refs, int *count)
     *count = c;
 
     av_free(*refs);
-    *refs = av_calloc(*count, sizeof(UID));
+    *refs = av_malloc(*count * sizeof(UID));
     if (!*refs) {
         *count = 0;
         return AVERROR(ENOMEM);