diff mbox series

[FFmpeg-devel,1/6] avformat/mxfdec: Do not clear arrays in mxf_read_index_entry_array()

Message ID 20201227174938.27369-1-michael@niedermayer.cc
State New
Headers show
Series [FFmpeg-devel,1/6] avformat/mxfdec: Do not clear arrays in mxf_read_index_entry_array()
Related show

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

Michael Niedermayer Dec. 27, 2020, 5:49 p.m. UTC
They are written too immediately, so it should not be needed.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavformat/mxfdec.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

James Almer Dec. 27, 2020, 6:05 p.m. UTC | #1
On 12/27/2020 2:49 PM, Michael Niedermayer wrote:
> They are written too immediately, so it should not be needed.
> 
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>   libavformat/mxfdec.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
> index 1f79f3d3cd..f5472525ff 100644
> --- a/libavformat/mxfdec.c
> +++ b/libavformat/mxfdec.c
> @@ -1088,9 +1088,9 @@ static int mxf_read_index_entry_array(AVIOContext *pb, MXFIndexTableSegment *seg
>       if(segment->nb_index_entries && length < 11)
>           return AVERROR_INVALIDDATA;
>   
> -    if (!(segment->temporal_offset_entries=av_calloc(segment->nb_index_entries, sizeof(*segment->temporal_offset_entries))) ||
> -        !(segment->flag_entries          = av_calloc(segment->nb_index_entries, sizeof(*segment->flag_entries))) ||
> -        !(segment->stream_offset_entries = av_calloc(segment->nb_index_entries, sizeof(*segment->stream_offset_entries)))) {
> +    if (!(segment->temporal_offset_entries=av_malloc_array(segment->nb_index_entries, sizeof(*segment->temporal_offset_entries))) ||
> +        !(segment->flag_entries          = av_malloc_array(segment->nb_index_entries, sizeof(*segment->flag_entries))) ||
> +        !(segment->stream_offset_entries = av_malloc_array(segment->nb_index_entries, sizeof(*segment->stream_offset_entries)))) {

Should be ok. And align these vertically and properly, while at it.

>           av_freep(&segment->temporal_offset_entries);
>           av_freep(&segment->flag_entries);
>           return AVERROR(ENOMEM);
>
Andreas Rheinhardt Dec. 27, 2020, 6:11 p.m. UTC | #2
Michael Niedermayer:
> They are written too immediately, so it should not be needed.
> 
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavformat/mxfdec.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
> index 1f79f3d3cd..f5472525ff 100644
> --- a/libavformat/mxfdec.c
> +++ b/libavformat/mxfdec.c
> @@ -1088,9 +1088,9 @@ static int mxf_read_index_entry_array(AVIOContext *pb, MXFIndexTableSegment *seg
>      if(segment->nb_index_entries && length < 11)
>          return AVERROR_INVALIDDATA;
>  
> -    if (!(segment->temporal_offset_entries=av_calloc(segment->nb_index_entries, sizeof(*segment->temporal_offset_entries))) ||
> -        !(segment->flag_entries          = av_calloc(segment->nb_index_entries, sizeof(*segment->flag_entries))) ||
> -        !(segment->stream_offset_entries = av_calloc(segment->nb_index_entries, sizeof(*segment->stream_offset_entries)))) {
> +    if (!(segment->temporal_offset_entries=av_malloc_array(segment->nb_index_entries, sizeof(*segment->temporal_offset_entries))) ||
> +        !(segment->flag_entries          = av_malloc_array(segment->nb_index_entries, sizeof(*segment->flag_entries))) ||
> +        !(segment->stream_offset_entries = av_malloc_array(segment->nb_index_entries, sizeof(*segment->stream_offset_entries)))) {
>          av_freep(&segment->temporal_offset_entries);
>          av_freep(&segment->flag_entries);
>          return AVERROR(ENOMEM);
> 
Maybe use FF_ALLOC_TYPED_ARRAY? Anyway, both the current as well as your
proposed version don't have spaces around the first assignment and the
assignments are not properly aligned.

- Andreas
Michael Niedermayer Dec. 28, 2020, 6:35 p.m. UTC | #3
On Sun, Dec 27, 2020 at 07:11:19PM +0100, Andreas Rheinhardt wrote:
> Michael Niedermayer:
> > They are written too immediately, so it should not be needed.
> > 
> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > ---
> >  libavformat/mxfdec.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> > 
> > diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
> > index 1f79f3d3cd..f5472525ff 100644
> > --- a/libavformat/mxfdec.c
> > +++ b/libavformat/mxfdec.c
> > @@ -1088,9 +1088,9 @@ static int mxf_read_index_entry_array(AVIOContext *pb, MXFIndexTableSegment *seg
> >      if(segment->nb_index_entries && length < 11)
> >          return AVERROR_INVALIDDATA;
> >  
> > -    if (!(segment->temporal_offset_entries=av_calloc(segment->nb_index_entries, sizeof(*segment->temporal_offset_entries))) ||
> > -        !(segment->flag_entries          = av_calloc(segment->nb_index_entries, sizeof(*segment->flag_entries))) ||
> > -        !(segment->stream_offset_entries = av_calloc(segment->nb_index_entries, sizeof(*segment->stream_offset_entries)))) {
> > +    if (!(segment->temporal_offset_entries=av_malloc_array(segment->nb_index_entries, sizeof(*segment->temporal_offset_entries))) ||
> > +        !(segment->flag_entries          = av_malloc_array(segment->nb_index_entries, sizeof(*segment->flag_entries))) ||
> > +        !(segment->stream_offset_entries = av_malloc_array(segment->nb_index_entries, sizeof(*segment->stream_offset_entries)))) {
> >          av_freep(&segment->temporal_offset_entries);
> >          av_freep(&segment->flag_entries);
> >          return AVERROR(ENOMEM);
> > 
> Maybe use FF_ALLOC_TYPED_ARRAY? Anyway, both the current as well as your
> proposed version don't have spaces around the first assignment and the
> assignments are not properly aligned.

will apply with these changes

thx

[...]
diff mbox series

Patch

diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 1f79f3d3cd..f5472525ff 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -1088,9 +1088,9 @@  static int mxf_read_index_entry_array(AVIOContext *pb, MXFIndexTableSegment *seg
     if(segment->nb_index_entries && length < 11)
         return AVERROR_INVALIDDATA;
 
-    if (!(segment->temporal_offset_entries=av_calloc(segment->nb_index_entries, sizeof(*segment->temporal_offset_entries))) ||
-        !(segment->flag_entries          = av_calloc(segment->nb_index_entries, sizeof(*segment->flag_entries))) ||
-        !(segment->stream_offset_entries = av_calloc(segment->nb_index_entries, sizeof(*segment->stream_offset_entries)))) {
+    if (!(segment->temporal_offset_entries=av_malloc_array(segment->nb_index_entries, sizeof(*segment->temporal_offset_entries))) ||
+        !(segment->flag_entries          = av_malloc_array(segment->nb_index_entries, sizeof(*segment->flag_entries))) ||
+        !(segment->stream_offset_entries = av_malloc_array(segment->nb_index_entries, sizeof(*segment->stream_offset_entries)))) {
         av_freep(&segment->temporal_offset_entries);
         av_freep(&segment->flag_entries);
         return AVERROR(ENOMEM);