[FFmpeg-devel] [PATCH 1/3] avformat/mxfdec: Fix memleak when adding element to array fails

Tomas Härdin tjoppen at acc.umu.se
Wed Jul 22 15:35:43 EEST 2020


mån 2020-07-20 klockan 08:15 +0200 skrev Andreas Rheinhardt:
> Said array contains pointers to other structs and both the designated
> new element as well as other stuff contained in it (e.g. strings)
> leak
> if the new element can't be added to the array.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
> ---
>  libavformat/mxfdec.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
> index 90546d42b3..08ad92cc0c 100644
> --- a/libavformat/mxfdec.c
> +++ b/libavformat/mxfdec.c
> @@ -822,15 +822,17 @@ static int mxf_read_partition_pack(void *arg,
> AVIOContext *pb, int tag, int size
>      return 0;
>  }
>  
> -static int mxf_add_metadata_set(MXFContext *mxf, void *metadata_set)
> +static int mxf_add_metadata_set(MXFContext *mxf, MXFMetadataSet
> **metadata_set)
>  {
>      MXFMetadataSet **tmp;
>  
>      tmp = av_realloc_array(mxf->metadata_sets, mxf-
> >metadata_sets_count + 1, sizeof(*mxf->metadata_sets));
> -    if (!tmp)
> +    if (!tmp) {
> +        mxf_free_metadataset(metadata_set, 1);

Went and double-checked that mxf_free_metadataset nulls *metadata_set
which it does, so this patch OK.

/Tomas



More information about the ffmpeg-devel mailing list