[FFmpeg-devel] [PATCH 2/3] avformat/vividas: Check allocation for success

Zane van Iperen zane at zanevaniperen.com
Thu Aug 6 04:09:23 EEST 2020


On Thu, 6 Aug 2020 01:33:57 +0200
"Andreas Rheinhardt" <andreas.rheinhardt at gmail.com> wrote:

> 
>  static void load_sb_block(AVFormatContext *s, VividasDemuxContext *viv, unsigned expected_size)
> @@ -608,7 +606,7 @@ static int viv_read_header(AVFormatContext *s)
>      ret = track_index(viv, s, buf, v);
>      av_free(buf);
>      if (ret < 0)
> -        return ret;
> +        goto fail;
> 
>      viv->sb_offset = avio_tell(pb);
>      if (viv->n_sb_blocks > 0) {
> @@ -619,6 +617,9 @@ static int viv_read_header(AVFormatContext *s)
>      }
> 
>      return 0;
> +fail:
> +    av_freep(&viv->sb_blocks);
> +    return ret;
>  }

Nit: Considering there's only one `goto fail`, wouldn't it be better to
just av_freep and return immediately instead?

Otherwise, all lgtm.

Zane



More information about the ffmpeg-devel mailing list